Class Index | File Index

## Classes

- _Association
- _global_
- Dataset
- ManyToMany
- ManyToOne
- MayToOne
- Migrations
- Model
- moose
- moose.adapters
- moose.adapters.client.Client
- moose.adapters.client.ConnectionPool
- moose.adapters.client.mysql.ConnectionPool
- moose.adapters.client.mysql.Query
- moose.adapters.client.mysql.TransactionQuery
- moose.adapters.mysql
- moose.adapters.mysql.types
- moose.plugins
- moose.plugins.AssociationPlugin
- moose.plugins.CachePlugin
- moose.plugins.QueryPlugin
- moose.plugins.TimeStampPlugin
- moose.Table
- OneToMany
- SQL
- Type

# Class Dataset

Extends SQL.
Wrapper for SQL adpaters to allow execution functions such as:

- forEach
- one
- all
- first
- last
- all
- save

This class should be used insead of SQL directly, becuase:

- 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.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| Dataset()

Fields borrowed from class SQL:
  sql

Method Summary
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

Class Detail
Dataset()
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.

Documentation generated by JsDoc Toolkit 2.4.0 on Sat Jun 11 2011 03:16:39 GMT-0500 (CDT)