Class Dataset
Extends
SQL.
Wrapper for SQL adpaters to allow execution functions such as:
- forEach
- one
- all
- first
- last
- all
- save
- Allows for Model creation if needed
- Handles the massaging of data to make the use of results easier.
- Closing of database connections
Defined in: dataset.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Dataset()
|
Method Attributes | Method Name and Description |
---|---|
all(callback, errback)
Retrieve all rows from the query.
|
|
first(callback, errback)
Retrieve the first result from an ordered query.
|
|
forEach(callback, errback, scope)
Provide Array style looping a query results.
|
|
getLastInsertId(callback, errback)
Retrieve the last inserted id from the database.
|
|
last(callback, errback)
Retrieve the last result from an ordered query.
|
|
one(callback, errback)
Retrieve one row result from the query.
|
|
run(callback, errback)
Alias for Dataset#all
|
|
save(callback, errback, callback, errback)
Save values to a table.
|
- Methods borrowed from class SQL:
- and, avg, between, bitAnd, bitOr, bitXor, clear, clearHaving, clearLimit, clearOffset, clearOrder, close, count, crossJoin, distinct, end, eq, exec, find, format, fullJoin, fullOuterJoin, group, groupAndAvg, groupAndBitAnd, groupAndBitOr, groupAndBitXor, groupAndCount, groupAndMax, groupAndMin, groupAndStd, groupAndStdDev, groupAndStdDevPop, groupAndStdDevSamp, groupAndSum, groupAndVariance, groupAndVarPop, groupAndVarSamp, gt, gte, having, innerJoin, is, isNot, isNotNull, isNull, join, leftJoin, leftOuterJoin, like, limit, logicGroup, lt, lte, max, min, naturalJoin, naturalLeftJoin, naturalRightJoin, neq, notBetween, notIn, notLike, offset, or, order, orderBy, remove, rightJoin, rightOuterJoin, select, std, stdDev, stdDevPop, stdDevSamp, sum, update, variance, varPop, varSamp, where
Method Detail
{comb.Promise}
all(callback, errback)
Retrieve all rows from the query.
dataset.all(function(r){ Do something.... }, function(err){ Do something... }); //OR dataset.all().then(function(r){ Do something.... }, function(err){ Do something... });
- Parameters:
- {Function} callback Optional
- executed with the results.
- {Function} errback Optional
- executed if an error occurs.
- Returns:
- {comb.Promise} called back with results or the error if one occurs.
{comb.Promise}
first(callback, errback)
Retrieve the first result from an ordered query.
dataset.first(function(r){ Do something.... }, function(err){ Do something... }); //OR dataset.first().then(function(r){ Do something.... }, function(err){ Do something... });
- Parameters:
- {Function} callback Optional
- executed with the row
- {Function} errback Optional
- executed if an error occurs.
- Returns:
- {comb.Promise} called back with result or the error if one occurs.
{comb.Promise}
forEach(callback, errback, scope)
Provide Array style looping a query results.
dataset.forEach(function(r, i){ console.log("Row %d", i); });
- Parameters:
- {Function} callback Optional
- executed for each row returned.
- {Function} errback Optional
- executed if an error occurs.
- {Object} scope Optional
- scope to execute the callback and errback in.
- Returns:
- {comb.Promise} called back with results or the error if one occurs.
{comb.Promise}
getLastInsertId(callback, errback)
Retrieve the last inserted id from the database.
dataset.getLastInsertId(function(r){ Do something.... }, function(err){ Do something... }); //OR dataset.getLastInsertId().then(function(r){ Do something.... }, function(err){ Do something... });
- Parameters:
- {Function} callback Optional
- executed with the id
- {Function} errback Optional
- executed if an error occurs.
- Returns:
- {comb.Promise} called back with id or the error if one occurs.
{comb.Promise}
last(callback, errback)
Retrieve the last result from an ordered query. If the query is not ordered then the result is ambiguous.
dataset.last(function(r){ Do something.... }, function(err){ Do something... }); //OR dataset.last().then(function(r){ Do something.... }, function(err){ Do something... });
- Parameters:
- {Function} callback Optional
- executed with the row
- {Function} errback Optional
- executed if an error occurs.
- Returns:
- {comb.Promise} called back with result or the error if one occurs.
{comb.Promise}
one(callback, errback)
Retrieve one row result from the query.
dataset.one(function(r){ Do something.... }, function(err){ Do something... }); //OR dataset.one().then(function(r){ Do something.... }, function(err){ Do something... });
- Parameters:
- {Function} callback Optional
- executed with the row
- {Function} errback Optional
- executed if an error occurs.
- Returns:
- {comb.Promise} called back with result or the error if one occurs.
run(callback, errback)
Alias for Dataset#all
- Parameters:
- callback
- errback
{comb.Promise}
save(callback, errback, callback, errback)
Save values to a table.
This should not be used directly
- Parameters:
- {Function} callback Optional
- executed with the row
- {Function} errback Optional
- executed if an error occurs.
- callback
- errback
- Returns:
- {comb.Promise} called back with results or the error if one occurs.