dataSource.disconnect(cb)

dataSource.discoverAndBuildModels(modelName, [options], [cb])

Discover and build models from the given owner/modelName

options

{String} owner/schema - The database owner/schema name
{Boolean} relations - If relations (primary key/foreign key) are navigated
{Boolean} all - Ifall owners are included
{Boolean} views - If views are included

Arguments

Name

Type

Description

modelName

String

The model name

[options]

Object

The options

[cb]

Function

The callback function

dataSource.discoverAndBuildModelsSync(modelName, [options])

Discover and build models from the given owner/modelName synchronously

options

{String} owner/schema - The database owner/schema name
{Boolean} relations - If relations (primary key/foreign key) are navigated
{Boolean} all - Ifall owners are included
{Boolean} views - If views are included

Arguments

Name

Type

Description

modelName

String

The model name

[options]

Object

The options

dataSource.discoverExportedForeignKeys(modelName, options, [cb])

Retrieves a description of the foreign key columns that reference the given table's primary key columns (the foreign keys exported by a table).
They are ordered by fkTableOwner, fkTableName, and keySeq.

dataSource.discoverSchemas(modelName, [options], [cb])

Discover schema from a given modelName/view

options

{String} owner/schema - The database owner/schema name
{Boolean} relations - If relations (primary key/foreign key) are navigated
{Boolean} all - Ifall owners are included
{Boolean} views - If views are included

Arguments

Name

Type

Description

modelName

String

The model name

[options]

Object

The options

[cb]

Function

The callback function

dataSource.discoverSchemasSync(modelName, [options])

Discover schema from a given table/view synchronously

options

{String} owner/schema - The database owner/schema name
{Boolean} relations - If relations (primary key/foreign key) are navigated
{Boolean} all - Ifall owners are included
{Boolean} views - If views are included

Arguments

Name

Type

Description

modelName

String

The model name

[options]

Object

The options

dataSource.enableRemote(operation)

Enable remote access to a data source operation. Each connector has its own set of set
remotely enabled and disabled operations. To list the operations, call dataSource.operations().

geoPoint.toString()

Simple serialization.

Class: DataAccessObject

DataAccessObject

Base class for all persistent objects.
Provides a common API to access any database connector.
This class describes only abstract behavior. Refer to the specific connector (lib/connectors/*.js) for details.

DataAccessObject mixes Inclusion classes methods.

Arguments

Name

Type

Description

data

Object

Initial object data

Class: DataAccessObject Static Methods

DataAccessObject.count(where, cb)

Return count of matched records

Arguments

Name

Type

Description

where

Object

Search conditions (optional)

cb

Function

Callback, called with (err, count)

DataAccessObject.create(data, callback)

Create new instance of Model class, saved in database.
The callback function is called with arguments:

err (null or Error)

instance (null or Model)

Arguments

Name

Type

Description

data

{Object} Optional data object

callback

{Function} Callback function

DataAccessObject.exists(id, cb)

Check whether a model instance exists in database

Arguments

Name

Type

Description

id

id

Identifier of object (primary key value)

cb

Function

Callback function called with (err, exists: Bool)

DataAccessObject.find([query], params, callback)

Find all instances of Model, matched by query
make sure you have marked as index: true fields for filter or sort

Arguments

Name

Type

Description

[query]

Object

the query object

where: Object { key: val, key2: {gt: 'val2'}}

include: String, Object or Array. See DataAccessObject.include().

order: String

limit: Number

skip: Number

params

Object

(optional)

callback

Function

(required) called with two arguments: err (null or Error), array of instances

DataAccessObject.findById(id, cb)

Find object by id

Arguments

Name

Type

Description

id

Primary key value

cb

Function

Callback called with (err, instance)

DataAccessObject.findOne(query, cb)

Find one record, same as all, limited by 1 and return object, not collection

Arguments

Name

Type

Description

query

Object

search conditions: {where: {test: 'me'}}

cb

Function

callback called with (err, instance)

DataAccessObject.findOrCreate(query, data, cb)

Find one record, same as all, limited by 1 and return object, not collection,
if not found, create using data provided as second argument

Arguments

Name

Type

Description

query

Object

Search conditions: {where: {test: 'me'}}.

data

Object

Object to create.

cb

Function

Callback called with (err, instance)

DataAccessObject.remove([where], [cb])

Destroy all matching records

Arguments

Name

Type

Description

[where]

Object

An object that defines the criteria

[cb]

Function

Callback called with (err)

DataAccessObject.removeById(id, cb)

Destroy a record by id

Arguments

Name

Type

Description

id

The id value

cb

Function

Callback called with (err)

DataAccessObject.scope(name, query, [targetClass])

Define a scope for the model class. Scopes enable you to specify commonly-used
queries that you can reference as method calls on a model.

Arguments

Name

Type

Description

name

String

The scope name

query

Object

The query object for DataAccessObject.find()

[targetClass]

ModelClass

The model class for the query, default to the declaring model

DataAccessObject.upsert(data, callback)

Update or insert a model instance.

Arguments

Name

Type

Description

data

Object

The model instance data

callback

Function

The callback function (optional).

Class: DataAccessObject Instance Methods

dataAccessObject.reload(callback)

Reload object from persistence
Requires id member of object to be able to call find

The related object is cached, so if later you try to get again the author, no additional request will be made.
But there is an optional boolean parameter in first position that set whether or not you want to reload the cache:

post.author(true, function(err, user) {
// The user is reloaded, even if it was already cached.
});

This optional parameter default value is false, so the related object will be loaded from cache if available.

Class: Validatable

Validatable

Validation mixins for LoopBack models.

This class provides methods that add validation cababilities to models.
Each of this validations run when obj.isValid() method called.

Each configurator can accept n params (n-1 field names and one config). Config
is {Object} depends on specific validation, but all of them has one common part:
message member. It can be just string, when only one situation possible,
e.g. Post.validatesPresenceOf('title', { message: 'can not be blank' });