Add a multiple rows to the table - OK /*createEach: function (connectionName, table, valuesList, cb) {
if (LOG_DEBUG) {
console.log("BEGIN createEach");
}

var connectionObject = connections[connectionName];
var collection = connectionObject.collections[table];
var tableName = table;
var records = [];
var i = 0;

asynk.each(valuesList, function (data, cb) {

Prepare values

Object.keys(data).forEach(function (value) {
data[value] = utils.prepareValue(data[value]);
});

var attributes = collection.attributes;
var definition = collection.definition;
Object.keys(attributes).forEach(function (attributeName) {
var attribute = attributes[attributeName];
searching for column name, if it doesn't exist, we'll use attribute name
var columnName = attribute.columnName || attributeName;
affecting values to add to the columns
data[columnName] = data[attributeName];
deleting attributesto be added and their names are differnet from columns names
if (attributeName !== columnName)
delete data[attributeName];
deleting not mapped attributes
if ((_.isUndefined(definition[columnName])) || (_.isUndefined(data[columnName])))
delete data[columnName];
if (fieldIsDatetime(attribute)) {
data[columnName] = (!data[columnName]) ? 'null' : SqlString.dateField(data[columnName]);
}
});

var schema = collection.waterline.schema;
var _query;

var sequel = new Sequel(schema, sqlOptions);


Build a query for the specific query strategy
try {
_query = sequel.create(table, data);
} catch (e) {
return cb(e);
}
_query.query = _query.query.split( /\$/g).join(":");
_query.query = _query.query.split(" AS ").join(" ");
_query.query = _query.query.split(" RETURNING *").join("");

var keys = Object.keys(data);

for(var j=1; j<keys.length+1; j++){
_query.query = _query.query.replace(":" + j, ":" + keys[j - 1]);
}

for (key in data) {
if (data.hasOwnProperty(key)) {
var value = data[key]+'';
console.log(value);
if(value.indexOf("TO_TIMESTAMP") > -1){
data[key] = data[key].substring(1, data[key].length-1);
}
}
}
Run query
execQuery(connections[connectionName], _query.query, data, function (err, results) {
if (err) {
return cb(handleQueryError(err));
}
records.push(results.insertId);
i = i+1;
cb();
});
}).args(asynk.item, asynk.callback).parallel(function (err) {
if (err)
return cb(err);

var pk = 'id';

Object.keys(collection.definition).forEach(function (key) {
if (!collection.definition[key].hasOwnProperty('primaryKey'))
return;
pk = key;
});

If there are no records (`!records.length`)
then skip the query altogether- we don't need to look anything up
if (!records.length) {
return cb(null, []);
}

Build a Query to get newly inserted records
var query = 'SELECT * FROM ' + tableName.toUpperCase() + ' WHERE ' + pk + ' IN (' + records + ');';

Run Query returing results
connection.execute(query, [], function(err, results) {
if (err)
return cb(err);
cb(null, results);
});
cb(null, null);
}, [null]);
}, Count Query logic - PENDIENTE
function (connectionName, table, options, cb) {
            
            if (LOG_DEBUG) {
                console.log("BEGIN count");
            }
            
            // Grab Connection Schema
            var schema = {};
            var connectionObject = connections[connectionName];
            var collection = connectionObject.collections[table];

            Object.keys(connectionObject.collections).forEach(function (coll) {
                schema[coll] = connectionObject.collections[coll].schema;
            });

            // Build Query
            var _schema = connectionObject.schema;
            var processor = new Processor(_schema);

            // Mixin WL Next connection overrides to sqlOptions
            var overrides = connectionOverrides[connectionName] || {};
            var _options = _.cloneDeep(sqlOptions);
            if (hop(overrides, 'wlNext')) {
                _options.wlNext = overrides.wlNext;
            }

            var sequel = new Sequel(_schema, _options);
            var _query;

            // Build a query for the specific query strategy
            try {
                _query = sequel.count(table, options);
            } catch (e) {
                return cb(e);
            }


            // Run Query
            connectionObject.pool.getConnection(
                    function (err, connection)
                    {
                        if (err) {
                            handleQueryError(err, 'count');
                            return;
                        }
                        if (LOG_QUERIES) {
                            console.log('Executing query: ' + _query.query[0]);
                        }
                        connection.execute(_query.query[0], _query.values[0], {outFormat: oracledb.OBJECT}, function __COUNT__(err, result) {
                            if (err) {
                                /* Release the connection back to the connection pool */
                                doRelease(connection);
                                return cb(handleQueryError(err, 'count'));
                            }

                            if (!_.isArray(result.rows) || !result.rows.length) {
                                return cb(new Error('Invalid query, no results returned.'));
                            }
                            var count = result.rows[0] && result.rows[0].count;
                            /* Release the connection back to the connection pool */
                            doRelease(connection);

                            return cb(null, Number(count));

                        });
                    });
        }