Class: MongoDBAdapter

MongoDBAdapter


new MongoDBAdapter(opts)

MongoDBAdapter class.

Method parameters:
Name Type Argument Description
opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
debug Boolean <optional>
false

See Adapter#debug.

countOpts Object <optional>

See MongoDBAdapter#countOpts.

findOpts Object <optional>

See MongoDBAdapter#findOpts.

findOneOpts Object <optional>

See MongoDBAdapter#findOneOpts.

insertOpts Object <optional>

See MongoDBAdapter#insertOpts.

insertManyOpts Object <optional>

See MongoDBAdapter#insertManyOpts.

raw Boolean <optional>
false

See Adapter#raw.

removeOpts Object <optional>

See MongoDBAdapter#removeOpts.

translateId Boolean <optional>
true

See MongoDBAdapter#translateId.

updateOpts Object <optional>

See MongoDBAdapter#updateOpts.

uri String <optional>
"mongodb://localhost:27017"

See MongoDBAdapter#uri.

Details
Source
src/index.js, line 44
Example
// Use Container instead of DataStore on the server
import {Container} from 'js-data'
import MongoDBAdapter from 'js-data-mongodb'

// Create a store to hold your Mappers
const store = new Container({
  mapperDefaults: {
    // MongoDB uses "_id" as the primary key
    idAttribute: '_id'
  }
})

// Create an instance of MongoDBAdapter with default settings
const adapter = new MongoDBAdapter()

// Mappers in "store" will use the MongoDB adapter by default
store.registerAdapter('mongodb', adapter, { default: true })

// Create a Mapper that maps to a "user" collection
store.defineMapper('user')

Extends

This class extends the Adapter class.

Members


client

A Promise that resolves to a reference to the MongoDB client being used by this adapter.

Details
Type Source
Promise src/index.js, line 94

countOpts

Default options to pass to collection#count.

Details
Type Default value Source
Object
{}
src/index.js, line 114

debug

Whether to log debugging information.

Details
Type Default value Source
Boolean
false
node_modules/js-data-adapter/src/index.js, line 74
Inherited From:

findOneOpts

Default options to pass to collection#findOne.

Details
Type Default value Source
Object
{}
src/index.js, line 134

findOpts

Default options to pass to collection#find.

Details
Type Default value Source
Object
{}
src/index.js, line 124

insertManyOpts

Default options to pass to collection#insertMany.

Details
Type Default value Source
Object
{}
src/index.js, line 154

insertOpts

Default options to pass to collection#insert.

Details
Type Default value Source
Object
{}
src/index.js, line 144

raw

Whether to return a more detailed response object.

Details
Type Default value Source
Boolean
false
node_modules/js-data-adapter/src/index.js, line 83
Inherited From:

removeOpts

Default options to pass to collection#update.

Details
Type Default value Source
Object
{}
src/index.js, line 174

translateId

Convert ObjectIDs to strings when pulling records out of the database.

Details
Type Default value Source
Boolean
true
src/index.js, line 11

updateOpts

Default options to pass to collection#update.

Details
Type Default value Source
Object
{}
src/index.js, line 164

uri

MongoDB URI.

Details
Type Default value Source
String
mongodb://localhost:27017
src/index.js, line 26

Methods


<static> extend(props, classProps)

Create a subclass of this MongoDBAdapter:

Method parameters:
Name Type Argument Default Description
props Object <optional>
{}

Properties to add to the prototype of the subclass.

Properties
Name Type Argument Description
constructor Object <optional>

Provide a custom constructor function to be used as the subclass itself.

classProps Object <optional>
{}

Static properties to add to the subclass.

Return value:
Type Description
Constructor

Subclass of this MongoDBAdapter class.

Details
Since Source
3.0.0 src/index.js, line 1023
Example

// Normally you would do: import { MongoDBAdapter } from 'js-data-mongodb'
const JSDataMongoDB = require('js-data-mongodb')
const { MongoDBAdapter } = JSDataMongoDB
console.log('Using JSDataMongoDB v' + JSDataMongoDB.version.full)

// Extend the class using ES2015 class syntax.
class CustomMongoDBAdapterClass extends MongoDBAdapter {
  foo () { return 'bar' }
  static beep () { return 'boop' }
}
const customMongoDBAdapter = new CustomMongoDBAdapterClass()
console.log(customMongoDBAdapter.foo())
console.log(CustomMongoDBAdapterClass.beep())

// Extend the class using alternate method.
const OtherMongoDBAdapterClass = MongoDBAdapter.extend({
  foo () { return 'bar' }
}, {
  beep () { return 'boop' }
})
const otherMongoDBAdapter = new OtherMongoDBAdapterClass()
console.log(otherMongoDBAdapter.foo())
console.log(OtherMongoDBAdapterClass.beep())

// Extend the class, providing a custom constructor.
function AnotherMongoDBAdapterClass () {
  MongoDBAdapter.call(this)
  this.created_at = new Date().getTime()
}
MongoDBAdapter.extend({
  constructor: AnotherMongoDBAdapterClass,
  foo () { return 'bar' }
}, {
  beep () { return 'boop' }
})
const anotherMongoDBAdapter = new AnotherMongoDBAdapterClass()
console.log(anotherMongoDBAdapter.created_at)
console.log(anotherMongoDBAdapter.foo())
console.log(AnotherMongoDBAdapterClass.beep())

_translateId()

Translate ObjectIDs to strings.

Return value:
Type Description
* Unspecified
Details
Source
src/index.js, line 208

afterCount(mapper, props, opts, response)

Lifecycle method method called by count.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes count to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be the count.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by count.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to count.

props Object

The props argument passed to count.

opts Object

The opts argument passed to count.

response Object | Response

Count or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterCount

Inherited From:

afterCreate(mapper, props, opts, response)

Lifecycle method method called by create.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes create to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be the created record.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by create.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to create.

props Object

The props argument passed to create.

opts Object

The opts argument passed to create.

response Object | Response

Created record or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterCreate

Inherited From:

afterDestroy(mapper, id, opts, response)

Lifecycle method method called by destroy.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes destroy to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be undefined.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to destroy.

id String | Number

The id argument passed to destroy.

opts Object

The opts argument passed to destroy.

response undefined | Response

undefined or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterDestroy

Inherited From:

afterDestroyAll(mapper, query, opts, response)

Lifecycle method method called by destroyAll.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be undefined.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to destroyAll.

query Object

The query argument passed to destroyAll.

opts Object

The opts argument passed to destroyAll.

response undefined | Response

undefined or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterDestroyAll

Inherited From:

afterFind(mapper, id, opts, response)

Lifecycle method method called by find.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes find to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be the found record, if any.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by find.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to find.

id String | Number

The id argument passed to find.

opts Object

The opts argument passed to find.

response Object | Response

The found record or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterFind

Inherited From:

afterFindAll(mapper, query, opts, response)

Lifecycle method method called by findAll.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes findAll to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be the found records, if any.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to findAll.

query Object

The query argument passed to findAll.

opts Object

The opts argument passed to findAll.

response Array.<Object> | Response

The found records or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterFindAll

Inherited From:

afterSum(mapper, field, query, opts, response)

Lifecycle method method called by sum.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes sum to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be the sum.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to sum.

field String

The field argument passed to sum.

query Object

The query argument passed to sum.

opts Object

The opts argument passed to sum.

response Object | Response

Count or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterSum

Inherited From:

afterUpdate(mapper, id, props, opts, response)

Lifecycle method method called by update.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes update to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be the updated record.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by update.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to update.

id String | Number

The id argument passed to update.

props Object

The props argument passed to update.

opts Object

The opts argument passed to update.

response Object | Response

The updated record or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterUpdate

Inherited From:

afterUpdateAll(mapper, props, query, opts, response)

Lifecycle method method called by updateAll.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be the updated records, if any.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to updateAll.

props Object

The props argument passed to updateAll.

query Object

The query argument passed to updateAll.

opts Object

The opts argument passed to updateAll.

response Array.<Object> | Response

The updated records or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterUpdateAll

Inherited From:

afterUpdateMany(mapper, records, opts, response)

Lifecycle method method called by updateMany.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.

If opts.raw is true then response will be a detailed response object, otherwise response will be the updated records, if any.

response may be modified. You can also re-assign response to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to updateMany.

records Array.<Object>

The records argument passed to updateMany.

opts Object

The opts argument passed to updateMany.

response Array.<Object> | Response

The updated records or Response, depending on the value of opts.raw.

Properties:
Name Type Description
opts.op String

afterUpdateMany

Inherited From:

beforeCount(mapper, query, opts)

Lifecycle method method called by count.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes count to wait for the Promise to resolve before continuing.

A thrown error or rejected Promise will bubble up and reject the Promise returned by count.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to count.

query Object

The query argument passed to count.

opts Object

The opts argument passed to count.

Properties:
Name Type Description
opts.op String

beforeCount

Inherited From:

beforeCreate(mapper, props, opts)

Lifecycle method method called by create.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes create to wait for the Promise to resolve before continuing.

props may be modified. You can also re-assign props to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by create.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to create.

props Object

The props argument passed to create.

opts Object

The opts argument passed to create.

Properties:
Name Type Description
opts.op String

beforeCreate

Inherited From:

beforeCreateMany(mapper, props, opts)

Lifecycle method method called by createMany.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes createMany to wait for the Promise to resolve before continuing.

props may be modified. You can also re-assign props to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by createMany.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to createMany.

props Array.<Object>

The props argument passed to createMany.

opts Object

The opts argument passed to createMany.

Properties:
Name Type Description
opts.op String

beforeCreateMany

Inherited From:

beforeDestroy(mapper, id, opts)

Lifecycle method method called by destroy.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes destroy to wait for the Promise to resolve before continuing.

A thrown error or rejected Promise will bubble up and reject the Promise returned by destroy.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to destroy.

id String | Number

The id argument passed to destroy.

opts Object

The opts argument passed to destroy.

Properties:
Name Type Description
opts.op String

beforeDestroy

Inherited From:

beforeDestroyAll(mapper, query, opts)

Lifecycle method method called by destroyAll.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes destroyAll to wait for the Promise to resolve before continuing.

A thrown error or rejected Promise will bubble up and reject the Promise returned by destroyAll.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to destroyAll.

query Object

The query argument passed to destroyAll.

opts Object

The opts argument passed to destroyAll.

Properties:
Name Type Description
opts.op String

beforeDestroyAll

Inherited From:

beforeFind(mapper, id, opts)

Lifecycle method method called by find.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes find to wait for the Promise to resolve before continuing.

A thrown error or rejected Promise will bubble up and reject the Promise returned by find.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to find.

id String | Number

The id argument passed to find.

opts Object

The opts argument passed to find.

Properties:
Name Type Description
opts.op String

beforeFind

Inherited From:

beforeFindAll(mapper, query, opts)

Lifecycle method method called by findAll.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes findAll to wait for the Promise to resolve before continuing.

A thrown error or rejected Promise will bubble up and reject the Promise returned by findAll.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to findAll.

query Object

The query argument passed to findAll.

opts Object

The opts argument passed to findAll.

Properties:
Name Type Description
opts.op String

beforeFindAll

Inherited From:

beforeSum(mapper, query, opts)

Lifecycle method method called by sum.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes sum to wait for the Promise to resolve before continuing.

A thrown error or rejected Promise will bubble up and reject the Promise returned by sum.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to sum.

query Object

The query argument passed to sum.

opts Object

The opts argument passed to sum.

Properties:
Name Type Description
opts.op String

beforeSum

Inherited From:

beforeUpdate(mapper, id, props, opts)

Lifecycle method method called by update.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes update to wait for the Promise to resolve before continuing.

props may be modified. You can also re-assign props to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by update.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to update.

id String | Number

The id argument passed to update.

props Object

The props argument passed to update.

opts Object

The opts argument passed to update.

Properties:
Name Type Description
opts.op String

beforeUpdate

Inherited From:

beforeUpdateAll(mapper, props, query, opts)

Lifecycle method method called by updateAll.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes updateAll to wait for the Promise to resolve before continuing.

props may be modified. You can also re-assign props to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by updateAll.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to updateAll.

props Object

The props argument passed to updateAll.

query Object

The query argument passed to updateAll.

opts Object

The opts argument passed to updateAll.

Properties:
Name Type Description
opts.op String

beforeUpdateAll

Inherited From:

beforeUpdateMany(mapper, props, opts)

Lifecycle method method called by updateMany.

Override this method to add custom behavior for this lifecycle hook.

Returning a Promise causes updateMany to wait for the Promise to resolve before continuing.

props may be modified. You can also re-assign props to another value by returning a different value or a Promise that resolves to a different value.

A thrown error or rejected Promise will bubble up and reject the Promise returned by updateMany.

Method parameters:
Name Type Description
mapper Object

The mapper argument passed to updateMany.

props Array.<Object>

The props argument passed to updateMany.

opts Object

The opts argument passed to updateMany.

Properties:
Name Type Description
opts.op String

beforeUpdateMany

Inherited From:

count(mapper, query, opts)

Retrieve the number of records that match the selection query.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

query Object

Selection query.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
countOpts Object <optional>

Options to pass to collection#count.

raw Boolean <optional>
false

Whether to return a more detailed response object.

with Array.<String> <optional>
[]

Relations to eager load.

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 245 Adapter#count

create(mapper, props, opts)

Create a new record.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

props Object

The record to be created.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
insertOpts Object <optional>

Options to pass to collection#insert.

raw Boolean <optional>
false

Whether to return a more detailed

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 286 Adapter#create

createMany(mapper, props, opts)

Create multiple records in a single batch.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

props Object

The records to be created.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
insertManyOpts Object <optional>

Options to pass to collection#insertMany.

raw Boolean <optional>
false

Whether to return a more detailed response object.

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 338 Adapter#createMany

destroy(mapper, id, opts)

Destroy the record with the given primary key.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

id String | Number

Primary key of the record to destroy.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw Boolean <optional>
false

Whether to return a more detailed response object.

removeOpts Object <optional>

Options to pass to collection#remove.

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 384 Adapter#destroy

destroyAll(mapper, query, opts)

Destroy the records that match the selection query.

Method parameters:
Name Type Argument Description
mapper Object

the mapper.

query Object <optional>

Selection query.

Properties
Name Type Argument Description
where Object <optional>

Filtering criteria.

orderBy String | Array <optional>

Sorting criteria.

sort String | Array <optional>

Same as query.sort.

limit Number <optional>

Limit results.

skip Number <optional>

Offset results.

offset Number <optional>

Same as query.skip.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw Boolean <optional>
false

Whether to return a more detailed response object.

removeOpts Object <optional>

Options to pass to collection#remove.

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 431 Adapter#destroyAll

find(mapper, id, opts)

Retrieve the record with the given primary key.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

id String | Number

Primary key of the record to retrieve.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
fields String | Array.<String> | Object <optional>

Select a subset of fields to be returned.

findOneOpts Object <optional>

Options to pass to collection#findOne.

raw Boolean <optional>
false

Whether to return a more detailed response object.

with Array.<String> <optional>
[]

Relations to eager load.

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 487 Adapter#find

findAll(mapper, query, opts)

Retrieve the records that match the selection query.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

query Object

Selection query.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
fields String | Array.<String> | Object <optional>

Select a subset of fields to be returned.

findOpts Object <optional>

Options to pass to collection#find.

raw Boolean <optional>
false

Whether to return a more detailed response object.

with Array.<String> <optional>
[]

Relations to eager load.

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 537 Adapter#findAll

getClient()

Return a Promise that resolves to a reference to the MongoDB client being used by this adapter.

Useful when you need to do anything custom with the MongoDB client library.

Return value:
Type Description
Object

MongoDB client.

Details
Source
src/index.js, line 747

getOpt(opt, opts)

Resolve the value of the specified option based on the given options and this adapter's settings. Override with care.

Method parameters:
Name Type Argument Description
opt String

The name of the option.

opts Object <optional>

Configuration options.

Return value:
Type Description
*

The value of the specified option.

Inherited From:

getQuery()

Map filtering params in a selection query to MongoDB a filtering object.

Handles the following:

  • where
    • and bunch of filtering operators
Return value:
Type Description
Object Unspecified
Details
Source
src/index.js, line 760

getQueryOptions()

Map non-filtering params in a selection query to MongoDB query options.

Handles the following:

  • limit
  • skip/offset
  • orderBy/sort
Return value:
Type Description
Object Unspecified
Details
Source
src/index.js, line 883

loadBelongsTo()

Load a belongsTo relationship.

Override with care.

Return value:
Type Description
Promise Unspecified
Inherited From:

loadHasMany()

Load a hasMany relationship.

Override with care.

Return value:
Type Description
Promise Unspecified
Inherited From:

loadHasOne()

Load a hasOne relationship.

Override with care.

Return value:
Type Description
Promise Unspecified
Inherited From:

makeBelongsToForeignKey()

Return the foreignKey from the given record for the provided relationship.

Return value:
Type Description
* Unspecified

makeHasManyForeignKey()

Return the foreignKey from the given record for the provided relationship.

There may be reasons why you may want to override this method, like when the id of the parent doesn't exactly match up to the key on the child.

Override with care.

Return value:
Type Description
* Unspecified
Inherited From:

makeHasManyForeignKeys()

Return the foreignKeys from the given record for the provided relationship.

Override with care.

Return value:
Type Description
* Unspecified
Inherited From:

makeHasManyLocalKeys()

Return the localKeys from the given record for the provided relationship.

Override with care.

Return value:
Type Description
* Unspecified

respond(response, opts)

Method parameters:
Name Type Description
response Object

Response object.

opts Object

Configuration options. return {Object} If opts.raw == true then return response, else return response.data.

Inherited From:

sum(mapper, field, query, opts)

Retrieve sum of the specified field of the records that match the selection query. Called by Mapper#sum.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

field String

By to sum.

query Object <optional>

Selection query.

Properties
Name Type Argument Description
where Object <optional>

Filtering criteria.

orderBy String | Array <optional>

Sorting criteria.

sort String | Array <optional>

Same as query.sort.

limit Number <optional>

Limit results.

skip Number <optional>

Offset results.

offset Number <optional>

Same as query.skip.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw Boolean <optional>
false

Whether to return a more detailed response object.

Return value:
Type Description
Promise Unspecified
Inherited From:

toObjectID()

Turn an _id into an ObjectID if it isn't already an ObjectID.

Return value:
Type Description
* Unspecified
Details
Source
src/index.js, line 927

update(mapper, id, props, opts)

Apply the given update to the record with the specified primary key.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

id String | Number

The primary key of the record to be updated.

props Object

The update to apply to the record.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw Boolean <optional>
false

Whether to return a more detailed response object.

updateOpts Object <optional>

Options to pass to collection#update.

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 617 Adapter#update

updateAll(mapper, props, query, opts)

Apply the given update to all records that match the selection query.

Method parameters:
Name Type Argument Description
mapper Object

The mapper.

props Object

The update to apply to the selected records.

query Object <optional>

Selection query.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
raw Boolean <optional>
false

Whether to return a more detailed response object.

updateOpts Object <optional>

Options to pass to collection#update.

Return value:
Type Description
Promise Unspecified
Details
Source Overrides
src/index.js, line 680 Adapter#updateAll

updateMany()

Not supported.

Details
Source Overrides
src/index.js, line 964 Adapter#updateMany