Global

Members

(constant) Connector

Module dependencies.
Source:

(constant) EventEmitter

Module dependencies.
Source:

(constant) loopback

loopback ~ public api
Source:

Methods

Connector(options) → {Connector}

Create a new `Connector` with the given `options`.
Parameters:
Name Type Description
options Object
Source:
Returns:
Type
Connector

MailConnector()

Create an instance of the connector with the given `settings`.
Source:

Memory(options) → {Memory}

Create a new `Memory` connector with the given `options`.
Parameters:
Name Type Description
options Object
Source:
Returns:
Type
Memory

concatResults(previousResults, currentResults)

Concat current results into previous results Assumption made here that the previous results and current results are homogeneous
Parameters:
Name Type Description
previousResults Object | Array
currentResults Object | Array
Source:

downloadInChunks(filter, chunkSize, processFunction, cb)

Page async download calls
Parameters:
Name Type Description
filter Object filter object used for the async call
chunkSize Number size of each chunks
processFunction function the function to be called multiple times
cb function the callback
Source:

rest()

Expose models over REST. For example: ```js app.use(loopback.rest()); ``` For more information, see [Exposing models over a REST API](http://loopback.io/doc/en/lb2/Exposing-models-over-REST.html).
Source:

status()

Return [HTTP response](http://expressjs.com/4x/api.html#res.send) with basic application status information: date the application was started and uptime, in JSON format. For example: ```js { "started": "2014-06-05T00:26:49.750Z", "uptime": 9.394 } ```
Source:

token()

Check for an access token in cookies, headers, and query string parameters. This function always checks for the following: - `access_token` (params only) - `X-Access-Token` (headers only) - `authorization` (headers and cookies) It checks for these values in cookies, headers, and query string parameters _in addition_ to the items specified in the options parameter. **NOTE:** This function only checks for [signed cookies](http://expressjs.com/api.html#req.signedCookies). The following example illustrates how to check for an `accessToken` in a custom cookie, query string parameter and header called `foo-auth`. ```js app.use(loopback.token({ cookies: ['foo-auth'], headers: ['foo-auth', 'X-Foo-Auth'], params: ['foo-auth', 'foo_auth'] })); ```
Properties:
Name Type Attributes Description
cookies Array <optional>
Array of cookie names.
headers Array <optional>
Array of header names.
params Array <optional>
Array of param names.
searchDefaultTokenKeys Boolean <optional>
Use the default search locations for Token in request
enableDoublecheck Boolean <optional>
Execute middleware although an instance mounted earlier in the chain didn't find a token
overwriteExistingToken Boolean <optional>
only has effect in combination with `enableDoublecheck`. If truthy, will allow to overwrite an existing accessToken.
model function | String <optional>
AccessToken model name or class to use.
currentUserLiteral String <optional>
String literal for the current user.
bearerTokenBase64Encoded Boolean <optional>
Defaults to `true`. For `Bearer` token based `Authorization` headers, decode the value from `Base64`. If set to `false`, the decoding will be skipped and the token id will be the raw value parsed from the header.
Source:

uploadInChunks(largeArray, chunkSize, processFunction, cb)

Divide an async call with large array into multiple calls using smaller chunks
Parameters:
Name Type Description
largeArray Array the large array to be chunked
chunkSize Number size of each chunks
processFunction function the function to be called multiple times
cb function the callback
Source:

urlNotFound()

Convert any request not handled so far to a 404 error to be handled by error-handling middleware.
Source:

Type Definitions

callback(err, token)

Create a cryptographically random access token id.
Parameters:
Name Type Description
err Error
token String
Source:

callback(req, optionsopt, err, token)

Find a token for the given `ServerRequest`.
Parameters:
Name Type Attributes Description
req ServerRequest
options Object <optional>
Options for finding the token
err Error
token AccessToken
Source:

callback(err, isValid)

Validate the token.
Parameters:
Name Type Description
err Error
isValid Boolean
Source:

callback(principalType, principalId, model, property, accessType, err, result)

Check if the given principal is allowed to access the model/property
Parameters:
Name Type Description
principalType String The principal type.
principalId String The principal ID.
model String The model name.
property String The property/method/relation name.
accessType String The access type.
err String | Error The error object.
result AccessRequest The resolved access request.
Source:

callback(err, result)

Check if the request has the permission to access.
Parameters:
Name Type Description
err String | Error The error object.
result AccessRequest The resolved access request.
Properties:
Name Type Description
principals Array.<Object> An array of principals.
model String | Model The model name or model class.
modelId * The model instance ID.
property String The property/method/relation name.
accessType String The access type: READ, REPLICATE, WRITE, or EXECUTE.
Source:

callback(token, model, modelId, method, err, allowed)

Check if the given access token can invoke the method
Parameters:
Name Type Description
token AccessToken The access token
model String The model name
modelId * The model id
method String The method name
err String | Error The error object
allowed Boolean is the request allowed
Source:

callback(type, id, err, result)

Resolve a principal by type/id
Parameters:
Name Type Description
type String Principal type - ROLE/APP/USER
id String | Number Principal id or name
err String | Error The error object
result Object An instance of principal (Role, Application or User)
Source:

callback(principalType, principalId, role, err, isMapped)

Check if the given principal is mapped to the role
Parameters:
Name Type Description
principalType String Principal type
principalId String | * Principal id/name
role String | * Role id/name
err String | Error The error object
isMapped Boolean is the ACL mapped to the role
Source:

callback(owner, name, options, err)

Register a new application
Parameters:
Name Type Description
owner String Owner's user ID.
name String Name of the application
options Object Other options
err Error
Source:

callback(err)

Reset keys for the application instance
Parameters:
Name Type Description
err Error
Source:

callback(appId, err)

Reset keys for a given application by the appId
Parameters:
Name Type Description
appId Any
err Error
Source:

callback(appId, key, err, matched)

Authenticate the application id and key.
Parameters:
Name Type Description
appId Any
key String
err Error
matched String The matching key; one of: - clientKey - javaScriptKey - restApiKey - windowsKey - masterKey
Source:

callback(modelName, modelIds, err, changes)

Track the recent change of the given modelIds.
Parameters:
Name Type Description
modelName String
modelIds Array
err Error
changes Array Changes that were tracked
Source:

callback(modelName, modelId, err, change)

Find or create a change for the given model.
Parameters:
Name Type Description
modelName String
modelId String
err Error
change Change
Source:

callback(err, change)

Update (or create) the change with the current revision.
Parameters:
Name Type Description
err Error
change Change
Source:

callback(err, rev)

Get a change's current revision based on current data.
Parameters:
Name Type Description
err Error
rev String The current revision
Source:

callback(modelName, since, remoteChanges, err, result)

Determine the differences for a given model since a given checkpoint. The callback will contain an error or `result`. **result** ```js { deltas: Array, conflicts: Array } ``` **deltas** An array of changes that differ from `remoteChanges`. **conflicts** An array of changes that conflict with `remoteChanges`.
Parameters:
Name Type Description
modelName String
since Number Compare changes after this checkpoint
remoteChanges Array.<Change> A set of changes to compare
err Error
result Object See above.
Source:

callback(err, source, target)

Fetch the conflicting models.
Parameters:
Name Type Description
err Error
source PersistedModel
target PersistedModel
Source:

callback(err, sourceChange, targetChange)

Get the conflicting changes.
Parameters:
Name Type Description
err Error
sourceChange Change
targetChange Change
Source:

callback(err)

Resolve the conflict. Set the source change's previous revision to the current revision of the (conflicting) target change. Since the changes are no longer conflicting and appear as if the source change was based on the target, they will be replicated normally as part of the next replicate() call. This is effectively resolving the conflict using the source version.
Parameters:
Name Type Description
err Error
Source:

callback(err)

Resolve the conflict using the instance data in the source model.
Parameters:
Name Type Description
err Error
Source:

callback(err)

Resolve the conflict using the instance data in the target model.
Parameters:
Name Type Description
err Error
Source:

callback(data, err)

Resolve the conflict using the supplied instance data.
Parameters:
Name Type Description
data Object The set of changes to apply on the model instance. Use `null` value to delete the source instance instead.
err Error
Source:

callback(err, type)

Determine the conflict type. Possible results are - `Change.UPDATE`: Source and target models were updated. - `Change.DELETE`: Source and or target model was deleted. - `Change.UNKNOWN`: the conflict type is uknown or due to an error.
Parameters:
Name Type Description
err Error
type String The conflict type.
Source:

callback(err, checkpoint)

Get the current checkpoint id
Parameters:
Name Type Description
err Error
checkpoint Number The current checkpoint seq
Source:

callback(err, checkpoint)

Increase the current checkpoint if it already exists otherwise initialize it
Parameters:
Name Type Description
err Error
checkpoint Object The current checkpoint
Source:

callback(key, err, result)

Return the value associated with a given key.
Parameters:
Name Type Description
key String Key to use when searching the database.
err Error Error object.
result Any Value associated with the given key.
Source:

callback(key, value, err)

Persist a value and associate it with the given key.
Parameters:
Name Type Description
key String Key to associate with the given value.
value Any Value to persist.
err Error Error object.
Properties:
Name Type Description
ttl Number TTL for the key-value pair in ms.
Source:

callback(key, ttl, err)

Set the TTL (time to live) in ms (milliseconds) for a given key. TTL is the remaining time before a key-value pair is discarded from the database.
Parameters:
Name Type Description
key String Key to use when searching the database.
ttl Number TTL in ms to set for the key.
err Error Error object.
Source:

callback(key, error, ttl)

Return the TTL (time to live) for a given key. TTL is the remaining time before a key-value pair is discarded from the database.
Parameters:
Name Type Description
key String Key to use when searching the database.
error Error
ttl Number Expiration time for the key-value pair. `undefined` if TTL was not initially set.
Source:

callback(filter, options)

Return all keys in the database. **WARNING**: This method is not suitable for large data sets as all key-values pairs are loaded into memory at once. For large data sets, use `iterateKeys()` instead.
Parameters:
Name Type Description
filter Object An optional filter object with the following
Properties
Name Type Description
match String Glob string used to filter returned keys (i.e. `userid.*`). All connectors are required to support `*` and `?`, but may also support additional special characters specific to the database.
options Object
Source:

callback(err, application)

Get the application principal
Parameters:
Name Type Description
err Error
application Application
Source:

callback(err, user)

Get the user principal
Parameters:
Name Type Description
err Error
user User
Source:

callback(err, childUser)

Get the child role principal
Parameters:
Name Type Description
err Error
childUser User
Source:

callback(queryopt, err, list)

Fetch all users assigned to this role
Parameters:
Name Type Attributes Description
query object <optional>
query object passed to model find call
err String | Error The error string or object
list Array The list of users.
Source:

callback(queryopt, err, list)

Fetch all applications assigned to this role
Parameters:
Name Type Attributes Description
query object <optional>
query object passed to model find call
err String | Error The error string or object
list Array The list of applications.
Source:

callback(queryopt, err, list)

Fetch all roles assigned to this role
Parameters:
Name Type Attributes Description
query object <optional>
query object passed to model find call
err String | Error The error string or object
list Array The list of roles.
Source:

callback(modelClass, modelId, userId, principalType, err, isOwner)

Check if a given user ID is the owner the model instance.
Parameters:
Name Type Description
modelClass function The model class
modelId * The model ID
userId * The user ID
principalType String The user principalType (optional)
err String | Error The error string or object
isOwner Boolean True if the user is an owner.
Properties:
Name Type Description
The accessToken access token used to authorize the current user.
Source:

callback(context, err, isAuthenticated)

Check if the user ID is authenticated
Parameters:
Name Type Description
context Object The security context.
err Error Error object.
isAuthenticated Boolean True if the user is authenticated.
Source:

callback(role, context, err, isInRole)

Check if a given principal is in the specified role.
Parameters:
Name Type Description
role String The role name.
context Object The context object.
err Error Error object.
isInRole Boolean True if the principal is in the specified role.
Source:

callback(context, err, roles)

List roles for a given principal.
Parameters:
Name Type Description
context Object The security context.
err Error Error object.
roles Array.<String> An array of role IDs
Source:

callback(scope, model, property, accessType, err, result)

Check if the given scope is allowed to access the model/property
Parameters:
Name Type Description
scope String The scope name
model String The model name
property String The property/method/relation name
accessType String The access type
err String | Error The error object
result AccessRequest The access permission
Source:

callback(credentials, includeopt, err, token)

Login a user by with the given `credentials`. ```js User.login({username: 'foo', password: 'bar'}, function (err, token) { console.log(token.id); }); ``` If the `emailVerificationRequired` flag is set for the inherited user model and the email has not yet been verified then the method will return a 401 error that will contain the user's id. This id can be used to call the `api/verify` remote method to generate a new email verification token and send back the related email to the user.
Parameters:
Name Type Attributes Description
credentials Object username/password or email/password
include Array.<String> | String <optional>
Optionally set it to "user" to include the user info
err Error Error object
token AccessToken Access token if login is successful
Source:

callback(accessTokenID, err)

Logout a user with the given accessToken id. ```js User.logout('asd0a9f8dsj9s0s3223mk', function (err) { console.log(err || 'Logged out'); }); ```
Parameters:
Name Type Description
accessTokenID String
err Error
Source:

callback(password, err, isMatch)

Compare the given `password` with the users hashed password.
Parameters:
Name Type Description
password String The plain text password
err Error Error object
isMatch Boolean Returns true if the given `password` matches record
Source:

callback(userId, oldPassword, newPassword, optionsopt, err)

Change this user's password.
Parameters:
Name Type Attributes Description
userId * Id of the user changing the password
oldPassword string Current password, required in order to strongly verify the identity of the requesting user
newPassword string The new password to use.
options object <optional>
err Error Error object
Source:

callback(oldPassword, newPassword, optionsopt, err)

Change this user's password (prototype/instance version).
Parameters:
Name Type Attributes Description
oldPassword string Current password, required in order to strongly verify the identity of the requesting user
newPassword string The new password to use.
options object <optional>
err Error Error object
Source:

callback(userId, newPassword, optionsopt, err)

Set this user's password after a password-reset request was made.
Parameters:
Name Type Attributes Description
userId * Id of the user changing the password
newPassword string The new password to use.
options Object <optional>
Additional options including remoting context
err Error Error object
Source:

callback(newPassword, optionsopt, err)

Set this user's password. The callers of this method must ensure the client making the request is authorized to change the password, typically by providing the correct current password or a password-reset token.
Parameters:
Name Type Attributes Description
newPassword string The new password to use.
options Object <optional>
Additional options including remoting context
err Error Error object
Source:

callback(userId, token, redirect, err)

Confirm the user's identity.
Parameters:
Name Type Description
userId Any
token String The validation token
redirect String URL to redirect the user to once confirmed
err Error
Source:

callback(err)

Create a short lived access token for temporary login. Allows users to change passwords if forgotten.
Parameters:
Name Type Description
err Error
Properties:
Name Type Description
email String The user's email address
realm String The user's realm (optional)
Source:

callback(token, modelId, sharedMethod, ctx, err, allowed)

Check if the given access token can invoke the specified method.
Parameters:
Name Type Description
token AccessToken The access token.
modelId * The model ID.
sharedMethod SharedMethod The method in question.
ctx Object The remote invocation context.
err String | Error The error object.
allowed Boolean True if the request is allowed; false otherwise.
Source:

callback(err, app)

Get the `Application` object to which the Model is attached.
Parameters:
Name Type Description
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
app Application Attached application object.
Source:

callback(dataopt, err, models)

Create new instance of Model, and save to database.
Parameters:
Name Type Attributes Description
data Object | Array.<Object> <optional>
Optional data argument. Can be either a single model instance or an array of instances.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
models Object Model instances or null.
Source:

callback(data, err, model)

Update or insert a model instance
Parameters:
Name Type Description
data Object The model instance data to insert.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
model Object Updated model instance.
Source:

callback(whereopt, data, err, model)

Update or insert a model instance based on the search criteria. If there is a single instance retrieved, update the retrieved model. Creates a new model if no model instances were found. Returns an error if multiple instances are found.
Parameters:
Name Type Attributes Description
where Object <optional>
`where` filter, like ``` { key: val, key2: {gt: 'val2'}, ...} ```
see [Where filter](http://loopback.io/doc/en/lb2/Where-filter.html#where-clause-for-other-methods).
data Object The model instance data to insert.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
model Object Updated model instance.
Source:

callback(data, err, model)

Replace or insert a model instance; replace existing record if one is found, such that parameter `data.id` matches `id` of model instance; otherwise, insert a new record.
Parameters:
Name Type Description
data Object The model instance data.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
model Object Replaced model instance.
Properties:
Name Type Description
validate Boolean Perform validation before saving. Default is true.
Source:

callback(data, err, instance, created)

Finds one record matching the optional filter object. If not found, creates the object using the data provided as second argument. In this sense it is the same as `find`, but limited to one object. Returns an object, not collection. If you don't provide the filter object argument, it tries to locate an existing object that matches the `data` argument.
Parameters:
Name Type Description
data Object Data to insert if object matching the `where` filter is not found.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
instance Object Model instance matching the `where` filter, if found.
created Boolean True if the instance does not exist and gets created.
Properties:
Name Type Description
fields String | Object | Array Identify fields to include in return result.
See [Fields filter](http://loopback.io/doc/en/lb2/Fields-filter.html).
include String | Object | Array See PersistedModel.include documentation.
See [Include filter](http://loopback.io/doc/en/lb2/Include-filter.html).
limit Number Maximum number of instances to return.
See [Limit filter](http://loopback.io/doc/en/lb2/Limit-filter.html).
order String Sort order: either "ASC" for ascending or "DESC" for descending.
See [Order filter](http://loopback.io/doc/en/lb2/Order-filter.html).
skip Number Number of results to skip.
See [Skip filter](http://loopback.io/doc/en/lb2/Skip-filter.html).
where Object Where clause, like ``` {where: {key: val, key2: {gt: val2}, ...}} ```
See [Where filter](http://loopback.io/doc/en/lb2/Where-filter.html#where-clause-for-queries).
Source:

callback(id, err, exists)

Check whether a model instance exists in database.
Parameters:
Name Type Description
id id Identifier of object (primary key value).
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
exists Boolean True if the instance with the specified ID exists; false otherwise.
Source:

callback(id, err, instance)

Find object by ID with an optional filter for include/fields.
Parameters:
Name Type Description
id * Primary key value
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
instance Object Model instance matching the specified ID or null if no instance matches.
Properties:
Name Type Description
fields String | Object | Array Identify fields to include in return result.
See [Fields filter](http://loopback.io/doc/en/lb2/Fields-filter.html).
include String | Object | Array See PersistedModel.include documentation.
See [Include filter](http://loopback.io/doc/en/lb2/Include-filter.html).
Source:

callback(err, models)

Find all model instances that match `filter` specification. See [Querying models](http://loopback.io/doc/en/lb2/Querying-data.html).
Parameters:
Name Type Description
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
models Array Model instances matching the filter, or null if none found.
Properties:
Name Type Description
fields String | Object | Array Identify fields to include in return result.
See [Fields filter](http://loopback.io/doc/en/lb2/Fields-filter.html).
include String | Object | Array See PersistedModel.include documentation.
See [Include filter](http://loopback.io/doc/en/lb2/Include-filter.html).
limit Number Maximum number of instances to return.
See [Limit filter](http://loopback.io/doc/en/lb2/Limit-filter.html).
order String Sort order: either "ASC" for ascending or "DESC" for descending.
See [Order filter](http://loopback.io/doc/en/lb2/Order-filter.html).
skip Number Number of results to skip.
See [Skip filter](http://loopback.io/doc/en/lb2/Skip-filter.html).
where Object Where clause, like ``` { where: { key: val, key2: {gt: 'val2'}, ...} } ```
See [Where filter](http://loopback.io/doc/en/lb2/Where-filter.html#where-clause-for-queries).
Source:

callback(err, model)

Find one model instance that matches `filter` specification. Same as `find`, but limited to one result; Returns object, not collection.
Parameters:
Name Type Description
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
model Array First model instance that matches the filter or null if none found.
Properties:
Name Type Description
fields String | Object | Array Identify fields to include in return result.
See [Fields filter](http://loopback.io/doc/en/lb2/Fields-filter.html).
include String | Object | Array See PersistedModel.include documentation.
See [Include filter](http://loopback.io/doc/en/lb2/Include-filter.html).
order String Sort order: either "ASC" for ascending or "DESC" for descending.
See [Order filter](http://loopback.io/doc/en/lb2/Order-filter.html).
skip Number Number of results to skip.
See [Skip filter](http://loopback.io/doc/en/lb2/Skip-filter.html).
where Object Where clause, like ``` {where: { key: val, key2: {gt: 'val2'}, ...} } ```
See [Where filter](http://loopback.io/doc/en/lb2/Where-filter.html#where-clause-for-queries).
Source:

callback(whereopt, err, info)

Destroy all model instances that match the optional `where` specification.
Parameters:
Name Type Attributes Description
where Object <optional>
Optional where filter, like: ``` {key: val, key2: {gt: 'val2'}, ...} ```
See [Where filter](http://loopback.io/doc/en/lb2/Where-filter.html#where-clause-for-other-methods).
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
info Object Additional information about the command outcome.
Properties
Name Type Description
count Number Number of instances (rows, documents) destroyed.
Source:

callback(whereopt, data, err, info)

Update multiple instances that match the where clause. Example: ```js Employee.updateAll({managerId: 'x001'}, {managerId: 'x002'}, function(err, info) { ... }); ```
Parameters:
Name Type Attributes Description
where Object <optional>
Optional `where` filter, like ``` { key: val, key2: {gt: 'val2'}, ...} ```
see [Where filter](http://loopback.io/doc/en/lb2/Where-filter.html#where-clause-for-other-methods).
data Object Object containing data to replace matching instances, if any.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
info Object Additional information about the command outcome.
Properties
Name Type Description
count Number Number of instances (rows, documents) updated.
Source:

callback(id, err)

Destroy model instance with the specified ID.
Parameters:
Name Type Description
id * The ID value of model instance to delete.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
Source:

callback(whereopt, err, count)

Return the number of records that match the optional "where" filter.
Parameters:
Name Type Attributes Description
where Object <optional>
Optional where filter, like ``` { key: val, key2: {gt: 'val2'}, ...} ```
See [Where filter](http://loopback.io/doc/en/lb2/Where-filter.html#where-clause-for-other-methods).
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
count Number Number of instances.
Source:

callback(err, instance)

Save model instance. If the instance doesn't have an ID, then calls [create](#persistedmodelcreatedata-cb) instead. Triggers: validate, save, update, or create.
Parameters:
Name Type Description
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
instance Object Model instance saved or created.
Properties:
Name Type Description
validate Boolean Perform validation before saving. Default is true.
throws Boolean If true, throw a validation error; WARNING: This can crash Node. If false, report the error via callback. Default is false.
Source:

callback(name, value, err, instance)

Update a single attribute. Equivalent to `updateAttributes({name: 'value'}, cb)`
Parameters:
Name Type Description
name String Name of property.
value Mixed Value of property.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
instance Object Updated instance.
Source:

callback(data, err, instance)

Update set of attributes. Performs validation before updating. Triggers: `validation`, `save` and `update` hooks
Parameters:
Name Type Description
data Object Data to update.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
instance Object Updated instance.
Source:

callback(data, err, instance)

Replace attributes for a model instance and persist it into the datasource. Performs validation before replacing.
Parameters:
Name Type Description
data Object Data to replace.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
instance Object Replaced instance.
Properties:
Name Type Description
validate Boolean Perform validation before saving. Default is true.
Source:

callback(id, data, err, instance)

Replace attributes for a model instance whose id is the first input argument and persist it into the datasource. Performs validation before replacing.
Parameters:
Name Type Description
id * The ID value of model instance to replace.
data Object Data to replace.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
instance Object Replaced instance.
Properties:
Name Type Description
validate Boolean Perform validation before saving. Default is true.
Source:

callback(err, instance)

Reload object from persistence. Requires `id` member of `object` to be able to call `find`.
Parameters:
Name Type Description
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
instance Object Model instance.
Source:

callback(since, remoteChanges, err, result)

Get a set of deltas and conflicts since the given checkpoint. See [Change.diff()](#change-diff) for details.
Parameters:
Name Type Description
since Number Find deltas since this checkpoint.
remoteChanges Array An array of change objects.
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
result Object Object with `deltas` and `conflicts` properties; see [Change.diff()](#change-diff) for details.
Source:

callback(since, filter, err, changes)

Get the changes to a model since the specified checkpoint. Provide a filter object to reduce the number of results returned.
Parameters:
Name Type Description
since Number Return only changes since this checkpoint.
filter Object Include only changes that match this filter, the same as for [#persistedmodel-find](find()).
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
changes Array An array of [Change](#change) objects.
Source:

callback(err, currentCheckpointId)

Get the current checkpoint ID.
Parameters:
Name Type Description
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
currentCheckpointId Number Current checkpoint ID.
Source:

callback(sinceopt, targetModel, optionsopt, err, conflicts, checkpoints)

Replicate changes since the given checkpoint to the given target model.
Parameters:
Name Type Attributes Description
since Number <optional>
Since this checkpoint
targetModel Model Target this model class
options Object <optional>
An optional options object to pass to underlying data-access calls.
Properties
Name Type Attributes Description
filter Object <optional>
Replicate models that match this filter
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
conflicts Array.<Conflict> A list of changes that could not be replicated due to conflicts.
checkpoints Object The new checkpoints to use as the "since" argument for the next replication.
Source:

callback(err, sourceId)

Get the source identifier for this model or dataSource.
Parameters:
Name Type Description
err Error Error object; see [Error object](http://loopback.io/doc/en/lb2/Error-object.html).
sourceId String Source identifier for the model or dataSource.
Source:

callback(id, err)

Specify that a change to the model with the given ID has occurred.
Parameters:
Name Type Description
id * The ID of the model that has changed.
err Error
Source:

callback(options, err, changes)

Create a change stream. [See here for more info](http://loopback.io/doc/en/lb2/Realtime-server-sent-events.html)
Parameters:
Name Type Description
options Object
Properties
Name Type Description
where Object Only changes to models matching this where filter will be included in the `ChangeStream`.
err Error
changes ChangeStream
Source:

callback(err)

Add custom data to the Change instance. Models should override this function to duplicate model instance properties to the Change instance properties, typically to allow the changes() method to filter the changes using these duplicated properties directly while querying the Change model. ```js module.exports = (TargetModel, config) => { TargetModel.prototype.fillCustomChangeProperties = function(change, cb) { var inst = this; const base = this.constructor.base; base.prototype.fillCustomChangeProperties.call(this, change, err => { if (err) return cb(err); if (inst && inst.tenantId) { change.tenantId = inst.tenantId; } else { change.tenantId = null; } cb(); }); }; }; ```
Parameters:
Name Type Description
err Error Error object; see [Error object](http://loopback.io/doc/en/lb3/Error-object.html).
Source:

cb(id, err, Resolved)

Resolve and validate the access token by id
Parameters:
Name Type Description
id String Access token
err Error Error information
Resolved Object access token object
Source:

cb(optionsopt, err, token)

Create access token for the logged in user. This method can be overridden to customize how access tokens are generated Supported flavours: ```js createAccessToken(ttl, cb) createAccessToken(ttl, options, cb); createAccessToken(options, cb); // recent addition: createAccessToken(data, options, cb); ```
Parameters:
Name Type Attributes Description
options Object <optional>
Additional options including remoting context
err String | Error The error string or object
token AccessToken The generated access token object
Properties:
Name Type Attributes Description
ttl Number <optional>
The requested ttl
scopes Array.<String> <optional>
The access scopes granted to the token.
Source:

cb(options, err, object)

Verify a user's identity by sending them a confirmation message. NOTE: Currently only email verification is supported ```js var verifyOptions = { type: 'email', from: 'noreply@example.com' template: 'verify.ejs', redirect: '/', generateVerificationToken: function (user, options, cb) { cb('random-token'); } }; user.verify(verifyOptions); ``` NOTE: the User.getVerifyOptions() method can also be used to ease the building of identity verification options. ```js var verifyOptions = MyUser.getVerifyOptions(); user.verify(verifyOptions); ```
Parameters:
Name Type Description
options Object remote context options.
err Error Error object.
object Object Contains email, token, uid.
Properties:
Name Type Description
type String Must be `'email'` in the current implementation.
mailer function A mailer function with a static `.send() method. The `.send()` method must accept the verifyOptions object, the method's remoting context options object and a callback function with `(err, email)` as parameters. Defaults to provided `userModel.email` function, or ultimately to LoopBack's own mailer function.
to String Email address to which verification email is sent. Defaults to user's email. Can also be overriden to a static value for test purposes.
from String Sender email address For example `'noreply@example.com'`.
subject String Subject line text. Defaults to `'Thanks for Registering'` or a local equivalent.
text String Text of email. Defaults to `'Please verify your email by opening this link in a web browser:` followed by the verify link.
headers Object Email headers. None provided by default.
template String Relative path of template that displays verification page. Defaults to `'../../templates/verify.ejs'`.
templateFn function A function generating the email HTML body from `verify()` options object and generated attributes like `options.verifyHref`. It must accept the verifyOptions object, the method's remoting context options object and a callback function with `(err, html)` as parameters. A default templateFn function is provided, see `createVerificationEmailBody()` for implementation details.
redirect String Page to which user will be redirected after they verify their email. Defaults to `'/'`.
verifyHref String The link to include in the user's verify message. Defaults to an url analog to: `http://host:port/restApiRoot/userRestPath/confirm?uid=userId&redirect=/``
host String The API host. Defaults to app's host or `localhost`.
protocol String The API protocol. Defaults to `'http'`.
port Number The API port. Defaults to app's port or `3000`.
restApiRoot String The API root path. Defaults to app's restApiRoot or `'/api'`
generateVerificationToken function A function to be used to generate the verification token. It must accept the verifyOptions object, the method's remoting context options object and a callback function with `(err, hexStringBuffer)` as parameters. This function should NOT add the token to the user object, instead simply execute the callback with the token! User saving and email sending will be handled in the `verify()` method. A default token generation function is provided, see `generateVerificationToken()` for implementation details.
Source:

filterCallback(relationName, pathName, filterMethod, paramName, getterName, hooks, SharedMethod, RelationDefinition)

Enabled deeply-nested queries of related models via REST API.
Parameters:
Name Type Description
relationName String Name of the nested relation.
pathName String The HTTP path (relative to the model) at which your remote method is exposed.
filterMethod String The filter name.
paramName String The argument name that the remote method accepts.
getterName String The getter name.
hooks Boolean Whether to inherit before/after hooks.
SharedMethod Object object. See [here](https://apidocs.strongloop.com/strong-remoting/#sharedmethod).
RelationDefinition Object object which includes relation `type`, `ModelConstructor` of `modelFrom`, `modelTo`, `keyFrom`, `keyTo` and more relation definitions.
Source: