new Container(opts)
The Container
class is a place to define and store Mapper instances.
A Container
makes it easy to manage your Mappers.
Name | Type | Argument | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
Object |
<optional> |
Configuration options. Properties
|
Since | Source |
---|---|
3.0.0 | Container.js, line 898 |
// import {Container} from 'js-data'
const JSData = require('js-data@3.0.0-beta.7')
const {Container} = JSData
console.log('Using JSData v' + JSData.version.full)
const store = new Container()
Extends
This class extends the Component class.Members
-
_adapters
-
The adapters registered with this Container, which are also shared by all Mappers in this Container.
DetailsType Since Source See Object 3.0.0 Container.js, line 925 -
_listeners
-
Event listeners attached to this Component. Do not modify. Use Component#on and Component#off instead.
DetailsType Since Source Object 3.0.0 Component.js, line 52 - Inherited From:
-
_mappers
-
The the mappers in this container
DetailsType Since Source See Object 3.0.0 Container.js, line 938 -
debug
-
Whether to enable debug-level logs for this component. Anything that extends
Component
inherits this option and the corresponding logging functionality.DetailsType Since Default value Source Boolean 3.0.0 false
Component.js, line 28 - Inherited From:
Example// Normally you would do: import {Component} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Component} = JSData console.log('Using JSData v' + JSData.version.full) const component = new Component() component.log('debug', 'some message') // nothing gets logged // Display debug logs: component.debug = true component.log('debug', 'other message') // this DOES get logged
-
mapperClass
-
Constructor function to use in Container#defineMapper to create new Mapper instances. Container#mapperClass should extend Mapper. By default Mapper is used to instantiate Mappers.
DetailsType Since Source See Constructor 3.0.0 Container.js, line 950 Example// import {Container, Mapper} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Container} = JSData console.log('Using JSData v' + JSData.version.full) class MyMapperClass extends Mapper { foo () { return 'bar' } } const store = new Container({ mapperClass: MyMapperClass }) store.defineMapper('user') console.log(store.getMapper('user').foo())
-
mapperDefaults
-
Defaults options to pass to Container#mapperClass when creating a new Mapper.
DetailsType Since Default value Source Object 3.0.0 {}
Container.js, line 984 Example// import {Container} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Container} = JSData console.log('Using JSData v' + JSData.version.full) const store = new Container({ mapperDefaults: { idAttribute: '_id' } }) store.defineMapper('user') console.log(store.getMapper('user').idAttribute)
Methods
-
<static> extend(props, classProps)
-
Create a subclass of this Container:
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 Container class.
DetailsSince Source 3.0.0 Container.js, line 1315 Example// Normally you would do: import {Container} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Container} = JSData console.log('Using JSData v' + JSData.version.full) // Extend the class using ES2015 class syntax. class CustomContainerClass extends Container { foo () { return 'bar' } static beep () { return 'boop' } } const customContainer = new CustomContainerClass() console.log(customContainer.foo()) console.log(CustomContainerClass.beep()) // Extend the class using alternate method. const OtherContainerClass = Container.extend({ foo () { return 'bar' } }, { beep () { return 'boop' } }) const otherContainer = new OtherContainerClass() console.log(otherContainer.foo()) console.log(OtherContainerClass.beep()) // Extend the class, providing a custom constructor. function AnotherContainerClass () { Container.call(this) this.created_at = new Date().getTime() } Container.extend({ constructor: AnotherContainerClass, foo () { return 'bar' } }, { beep () { return 'boop' } }) const anotherContainer = new AnotherContainerClass() console.log(anotherContainer.created_at) console.log(anotherContainer.foo()) console.log(AnotherContainerClass.beep())
-
as(name)
-
Return a container scoped to a particular mapper.
Return value:Type Description Object A container scoped to a particular mapper.
DetailsSince Source 3.0.0 Container.js, line 1056 Example// import {Container} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Container} = JSData console.log('Using JSData v' + JSData.version.full) const store = new Container() const UserMapper = store.defineMapper('user') const UserStore = store.as('user') const user1 = store.createRecord('user', { name: 'John' }) const user2 = UserStore.createRecord({ name: 'John' }) const user3 = UserMapper.createRecord({ name: 'John' }) console.log(user1 === user2) console.log(user2 === user3) console.log(user1 === user3)
-
count(name, query, opts)
-
Wrapper for Mapper#count.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
query
Object <optional>
See Mapper#count.
opts
Object <optional>
See Mapper#count.
Return value:Type Description Promise See Mapper#count.
DetailsSince Source See 3.0.0 Container.js, line 8 Example// Get the number of published blog posts import {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.count('post', { status: 'published' }).then((numPublished) => { console.log(numPublished) // e.g. 45 })
-
create(name, props, opts)
-
Wrapper for Mapper#create.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
props
Object See Mapper#create.
opts
Object <optional>
See Mapper#create.
Fires:
Return value:Type Description Promise See Mapper#create.
DetailsSince Source See 3.0.0 Container.js, line 84 Example// Create and save a new blog post import {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.create('post', { title: 'Modeling your data', status: 'draft' }).then((post) => { console.log(post) // { id: 1234, status: 'draft', ... } })
-
createMany(name, records, opts)
-
Wrapper for Mapper#createMany.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
records
Array.<Record> See Mapper#createMany.
opts
Object <optional>
See Mapper#createMany.
Fires:
Return value:Type Description Promise See Mapper#createMany.
DetailsSince Source See 3.0.0 Container.js, line 165 Example// Create and save several new blog posts import {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.createMany('post', [{ title: 'Modeling your data', status: 'draft' }, { title: 'Reading data', status: 'draft' }]).then((posts) => { console.log(posts[0]) // { id: 1234, status: 'draft', ... } console.log(posts[1]) // { id: 1235, status: 'draft', ... } })
-
createRecord(name, props, opts)
-
Wrapper for Mapper#createRecord.
Note: This method does not interact with any adapter, and does not save any data. It only creates new objects in memory.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
props
Object | Array.<Object> See Mapper#createRecord.
opts
Object <optional>
See Mapper#createRecord.
Return value:Type Description Promise See Mapper#createRecord.
DetailsSince Source See 3.0.0 Container.js, line 199 Example// Create empty unsaved record instance import {Container} from 'js-data' const store = new Container() store.defineMapper('post') const post = PostMapper.createRecord()
-
dbg(args)
-
Log the provided values at the "debug" level. Debug-level logs are only logged if Component#debug is
true
..dbg(...)
is shorthand for.log('debug', ...)
.Method parameters:Name Type Argument Description args
* <optional>
<repeatable>
Values to log.
DetailsSince Source 3.0.0 Component.js, line 123 - Inherited From:
-
defineMapper(name, opts)
-
Create a new mapper and register it in this container.
Method parameters:Name Type Argument Description name
String Name under which to register the new Mapper. Mapper#name will be set to this value.
opts
Object <optional>
Configuration options. Passed to Container#mapperClass when creating the new Mapper.
DetailsSince Source See 3.0.0 Container.js, line 1101 Example// import {Container} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Container} = JSData console.log('Using JSData v' + JSData.version.full) const store = new Container({ mapperDefaults: { foo: 'bar' } }) // Container#defineMapper returns a direct reference to the newly created // Mapper. const UserMapper = store.defineMapper('user') console.log(UserMapper === store.getMapper('user')) console.log(UserMapper === store.as('user').getMapper()) console.log(UserMapper.foo)
-
destroy(name, id, opts)
-
Wrapper for Mapper#destroy.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
id
String | Number See Mapper#destroy.
opts
Object <optional>
See Mapper#destroy.
Fires:
Return value:Type Description Promise See Mapper#destroy.
DetailsSince Source See 3.0.0 Container.js, line 273 Example// Destroy a specific blog post import {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.destroy('post', 1234).then(() => { // Blog post #1234 has been destroyed })
-
destroyAll(name, query, opts)
-
Wrapper for Mapper#destroyAll.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
query
Object <optional>
See Mapper#destroyAll.
opts
Object <optional>
See Mapper#destroyAll.
Fires:
Return value:Type Description Promise See Mapper#destroyAll.
DetailsSince Source See 3.0.0 Container.js, line 351 Example// Destroy all "draft" blog posts import {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.destroyAll('post', { status: 'draft' }).then(() => { // All "draft" blog posts have been destroyed })
-
emit(event, args)
-
Trigger an event on this Component.
Method parameters:Name Type Argument Description event
String Name of event to emit.
args
* <optional>
<repeatable>
Arguments to pass to any listeners.
DetailsSince Source 3.0.0 Component.js, line 201 - Inherited From:
Example// import {Collection, DataStore} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Collection, DataStore} = JSData const collection = new Collection() collection.on('foo', (msg) => { console.log(msg) }) collection.emit('foo', 'bar') const store = new DataStore() store.on('beep', (msg) => { console.log(msg) }) store.emit('beep', 'boop')
-
find(name, id, opts)
-
Wrapper for Mapper#find.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
id
String | Number See Mapper#find.
opts
Object <optional>
See Mapper#find.
Fires:
Return value:Type Description Promise See Mapper#find.
DetailsSince Source See 3.0.0 Container.js, line 429 Exampleimport {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.find('post', 1).then((post) => { console.log(post) // { id: 1, ...} })
-
findAll(name, query, opts)
-
Wrapper for Mapper#createRecord.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
query
Object <optional>
See Mapper#findAll.
opts
Object <optional>
See Mapper#findAll.
Fires:
Return value:Type Description Promise See Mapper#findAll.
DetailsSince Source See 3.0.0 Container.js, line 506 Example// Find all "published" blog posts import {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.findAll('post', { status: 'published' }).then((posts) => { console.log(posts) // [{ id: 1, ...}, ...] })
-
getAdapter(name)
-
Return the registered adapter with the given name or the default adapter if no name is provided.
Method parameters:Name Type Argument Description name
String <optional>
The name of the adapter to retrieve.
Return value:Type Description Adapter The adapter.
DetailsSince Source 3.0.0 Container.js, line 1173 -
getAdapterName(opts)
-
Return the name of a registered adapter based on the given name or options, or the name of the default adapter if no name provided.
Method parameters:Name Type Argument Description opts
Object | String <optional>
The name of an adapter or options, if any.
Return value:Type Description String The name of the adapter.
DetailsSince Source 3.0.0 Container.js, line 1190 -
getAdapters()
-
Return the registered adapters of this container.
Return value:Type Description Adapter Unspecified DetailsSince Source 3.0.0 Container.js, line 1207 -
getMapper(name)
-
Return the mapper registered under the specified name.
Method parameters:Name Type Description name
String Return value:Type Description Mapper Unspecified DetailsSince Source 3.0.0 Container.js, line 1218 Example// import {Container} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Container} = JSData console.log('Using JSData v' + JSData.version.full) const store = new Container() // Container#defineMapper returns a direct reference to the newly created // Mapper. const UserMapper = store.defineMapper('user') console.log(UserMapper === store.getMapper('user')) console.log(UserMapper === store.as('user').getMapper()) store.getMapper('profile') // throws Error, there is no mapper with name "profile"
-
getMapperByName(name)
-
Return the mapper registered under the specified name. Doesn't throw error if mapper doesn't exist.
Method parameters:Name Type Description name
String Return value:Type Description Mapper Unspecified DetailsSince Source 3.0.0 Container.js, line 1248 Example// import {Container} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Container} = JSData console.log('Using JSData v' + JSData.version.full) const store = new Container() // Container#defineMapper returns a direct reference to the newly created // Mapper. const UserMapper = store.defineMapper('user') console.log(UserMapper === store.getMapper('user')) console.log(UserMapper === store.as('user').getMapper()) console.log(store.getMapper('profile')) // Does NOT throw an error
-
getSchema(name)
-
Wrapper for Mapper#getSchema.
Return value:Type Description Schema See Mapper#getSchema.
DetailsSince Source See 3.0.0 Container.js, line 533 -
is(name, record)
-
Wrapper for Mapper#is.
Method parameters:Name Type Description name
String Name of the Mapper to target.
record
Object | Record See Mapper#is.
DetailsSince Source See 3.0.0 Container.js, line 544 Exampleimport {Container} from 'js-data' const store = new Container() store.defineMapper('post') const post = store.createRecord() console.log(store.is('post', post)) // true // Equivalent to what's above console.log(post instanceof store.getMapper('post').recordClass) // true
-
log(level, args)
-
Log the provided values. By default sends values to
console[level]
. Debug-level logs are only logged if Component#debug istrue
.Will attempt to use appropriate
console
methods if they are available.Method parameters:Name Type Argument Description level
String Log level.
args
* <optional>
<repeatable>
Values to log.
DetailsSince Source 3.0.0 Component.js, line 133 - Inherited From:
-
off(event, listener)
-
Remove an event listener from this Component. If no listener is provided, then all listeners for the specified event will be removed. If no event is specified then all listeners for all events will be removed.
Method parameters:Name Type Argument Description event
String <optional>
Name of event to unsubsribe to.
listener
Function <optional>
Listener to remove.
DetailsSince Source 3.0.0 Component.js, line 179 - Inherited From:
Examples// Remove a particular listener for a particular event collection.off('add', handler)
// Remove all listeners for a particular event record.off('change')
// Remove all listeners to all events store.off()
-
on(event, listener, ctx)
-
Register a new event listener on this Container.
Proxy for Component#on. If an event was emitted by a Mapper in the Container, then the name of the Mapper will be prepended to the arugments passed to the listener.
Method parameters:Name Type Argument Description event
String Name of event to subsribe to.
listener
Function Listener function to handle the event.
ctx
* <optional>
Optional content in which to invoke the listener.
DetailsSince Source Overrides 3.0.0 Container.js, line 1016 Component#on Example// import {Container} from 'js-data' const JSData = require('js-data@3.0.0-beta.7') const {Container} = JSData console.log('Using JSData v' + JSData.version.full) const store = new Container() store.on('foo', function (...args) { console.log(args.join(':')) }) store.defineMapper('user') store.emit('foo', 'arg1', 'arg2') store.getMapper('user').emit('foo', 'arg1', 'arg2')
-
registerAdapter(name, adapter, opts)
-
Register an adapter on this container under the given name. Adapters registered on a container are shared by all mappers in the container.
Method parameters:Name Type Argument Description name
String The name of the adapter to register.
adapter
Adapter The adapter to register.
opts
Object <optional>
Configuration options.
Properties
Name Type Argument Default Description default
Boolean <optional>
false Whether to make the adapter the default adapter for all Mappers in this container.
DetailsSince Source Tutorials 3.0.0 Container.js, line 1275 Exampleimport {Container} from 'js-data' import {RethinkDBAdapter} from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true })
-
sum(name, field, query, opts)
-
Wrapper for Mapper#sum.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
field
String See Mapper#sum.
query
Object <optional>
See Mapper#sum.
opts
Object <optional>
See Mapper#sum.
Return value:Type Description Promise See Mapper#sum.
DetailsSince Source See 3.0.0 Container.js, line 566 Exampleimport {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('purchase_order') store.sum('purchase_order', 'amount', { status: 'paid' }).then((amountPaid) => { console.log(amountPaid) // e.g. 451125.34 })
-
toJSON(name, records, opts)
-
Wrapper for Mapper#toJSON.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
records
Record | Array.<Record> See Mapper#toJSON.
opts
Object <optional>
See Mapper#toJSON.
Return value:Type Description Object | Array.<Object> See Mapper#toJSON.
DetailsSince Source See 3.0.0 Container.js, line 591 Exampleimport {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('person', { schema: { properties: { name: { type: 'string' }, id: { type: 'string' } } } }) const person = store.createRecord('person', { id: 1, name: 'John', foo: 'bar' }) console.log(store.toJSON('person', person)) // {"id":1,"name":"John","foo":"bar"} console.log(store.toJSON('person', person), { strict: true }) // {"id":1,"name":"John"}
-
update(name, id, record, opts)
-
Wrapper for Mapper#update.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
id
String | Number See Mapper#update.
record
Object See Mapper#update.
opts
Object <optional>
See Mapper#update.
Fires:
Return value:Type Description Promise See Mapper#update.
DetailsSince Source Tutorials See 3.0.0 Container.js, line 674 Exampleimport {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.update('post', 1234, { status: 'published', published_at: new Date() }).then((post) => { console.log(post) // { id: 1234, status: 'published', ... } })
-
updateAll(name, update, query, opts)
-
Wrapper for Mapper#updateAll.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
update
Object See Mapper#updateAll.
query
Object <optional>
See Mapper#updateAll.
opts
Object <optional>
See Mapper#updateAll.
Fires:
Return value:Type Description Promise See Mapper#updateAll.
DetailsSince Source See 3.0.0 Container.js, line 758 Example// Turn all of John's blog posts into drafts. import {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') const update = { status: draft: published_at: null } const query = { userId: 1234 } store.updateAll('post', update, query).then((posts) => { console.log(posts) // [...] })
-
updateMany(name, records, opts)
-
Wrapper for Mapper#updateMany.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
records
Array.<Object> | Array.<Record> See Mapper#updateMany.
opts
Object <optional>
See Mapper#updateMany.
Fires:
Return value:Type Description Promise See Mapper#updateMany.
DetailsSince Source See 3.0.0 Container.js, line 839 Exampleimport {Container} from 'js-data' import RethinkDBAdapter from 'js-data-rethinkdb' const store = new Container() store.registerAdapter('rethinkdb', new RethinkDBAdapter(), { default: true }) store.defineMapper('post') store.updateMany('post', [ { id: 1234, status: 'draft' }, { id: 2468, status: 'published', published_at: new Date() } ]).then((posts) => { console.log(posts) // [...] })
-
validate(name, records, opts)
-
Wrapper for Mapper#validate.
Method parameters:Name Type Argument Description name
String Name of the Mapper to target.
records
Array.<Object> | Array.<Record> See Mapper#validate.
opts
Object <optional>
See Mapper#validate.
Return value:Type Description Promise See Mapper#validate.
DetailsSince Source See 3.0.0 Container.js, line 868 Exampleimport {Container} from 'js-data' const store = new Container() store.defineMapper('post', { schema: { properties: { name: { type: 'string' }, id: { type: 'string' } } } }) let errors = store.validate('post', { name: 'John' }) console.log(errors) // undefined errors = store.validate('post', { name: 123 }) console.log(errors) // [{ expected: 'one of (string)', actual: 'number', path: 'name' }]
Type Definitions
-
afterCreateListener(name, props, opts, result)
-
Callback signature for the Container#event:afterCreate event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterCreate.props
Object The
props
argument received by Mapper#afterCreate.opts
Object The
opts
argument received by Mapper#afterCreate.result
Object The
result
argument received by Mapper#afterCreate.DetailsType Since Source See Function 3.0.0 Container.js, line 66 Examplefunction onAfterCreate (mapperName, props, opts, result) { // do something } store.on('afterCreate', onAfterCreate)
-
afterCreateManyListener(name, records, opts, result)
-
Callback signature for the Container#event:afterCreateMany event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterCreateMany.records
Object The
records
argument received by Mapper#afterCreateMany.opts
Object The
opts
argument received by Mapper#afterCreateMany.result
Object The
result
argument received by Mapper#afterCreateMany.DetailsType Since Source See Function 3.0.0 Container.js, line 147 Examplefunction onAfterCreateMany (mapperName, records, opts, result) { // do something } store.on('afterCreateMany', onAfterCreateMany)
-
afterDestroyAllListener(name, query, opts, result)
-
Callback signature for the Container#event:afterDestroyAll event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterDestroyAll.query
Object The
query
argument received by Mapper#afterDestroyAll.opts
Object The
opts
argument received by Mapper#afterDestroyAll.result
Object The
result
argument received by Mapper#afterDestroyAll.DetailsType Since Source See Function 3.0.0 Container.js, line 333 Examplefunction onAfterDestroyAll (mapperName, query, opts, result) { // do something } store.on('afterDestroyAll', onAfterDestroyAll)
-
afterDestroyListener(name, id, opts, result)
-
Callback signature for the Container#event:afterDestroy event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterDestroy.id
String | Number The
id
argument received by Mapper#afterDestroy.opts
Object The
opts
argument received by Mapper#afterDestroy.result
Object The
result
argument received by Mapper#afterDestroy.DetailsType Since Source See Function 3.0.0 Container.js, line 255 Examplefunction onAfterDestroy (mapperName, id, opts, result) { // do something } store.on('afterDestroy', onAfterDestroy)
-
afterFindAllListener(name, query, opts, result)
-
Callback signature for the Container#event:afterFindAll event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterFindAll.query
Object The
query
argument received by Mapper#afterFindAll.opts
Object The
opts
argument received by Mapper#afterFindAll.result
Object The
result
argument received by Mapper#afterFindAll.DetailsType Since Source See Function 3.0.0 Container.js, line 488 Examplefunction onAfterFindAll (mapperName, query, opts, result) { // do something } store.on('afterFindAll', onAfterFindAll)
-
afterFindListener(name, id, opts, result)
-
Callback signature for the Container#event:afterFind event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterFind.id
String | Number The
id
argument received by Mapper#afterFind.opts
Object The
opts
argument received by Mapper#afterFind.result
Object The
result
argument received by Mapper#afterFind.DetailsType Since Source See Function 3.0.0 Container.js, line 411 Examplefunction onAfterFind (mapperName, id, opts, result) { // do something } store.on('afterFind', onAfterFind)
-
afterUpdateAllListener(name, props, query, opts, result)
-
Callback signature for the Container#event:afterUpdateAll event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterUpdateAll.props
Object The
props
argument received by Mapper#afterUpdateAll.query
Object The
query
argument received by Mapper#afterUpdateAll.opts
Object The
opts
argument received by Mapper#afterUpdateAll.result
Object The
result
argument received by Mapper#afterUpdateAll.DetailsType Since Source See Function 3.0.0 Container.js, line 739 Examplefunction onAfterUpdateAll (mapperName, props, query, opts, result) { // do something } store.on('afterUpdateAll', onAfterUpdateAll)
-
afterUpdateListener(name, id, props, opts, result)
-
Callback signature for the Container#event:afterUpdate event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterUpdate.id
String | Number The
id
argument received by Mapper#afterUpdate.props
Object The
props
argument received by Mapper#afterUpdate.opts
Object The
opts
argument received by Mapper#afterUpdate.result
Object The
result
argument received by Mapper#afterUpdate.DetailsType Since Source See Function 3.0.0 Container.js, line 655 Examplefunction onAfterUpdate (mapperName, id, props, opts, result) { // do something } store.on('afterUpdate', onAfterUpdate)
-
afterUpdateManyListener(name, records, opts, result)
-
Callback signature for the Container#event:afterUpdateMany event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#afterUpdateMany.records
Object The
records
argument received by Mapper#afterUpdateMany.opts
Object The
opts
argument received by Mapper#afterUpdateMany.result
Object The
result
argument received by Mapper#afterUpdateMany.DetailsType Since Source See Function 3.0.0 Container.js, line 821 Examplefunction onAfterUpdateMany (mapperName, records, opts, result) { // do something } store.on('afterUpdateMany', onAfterUpdateMany)
-
beforeCreateListener(name, props, opts)
-
Callback signature for the Container#event:beforeCreate event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeCreate.props
Object The
props
argument received by Mapper#beforeCreate.opts
Object The
opts
argument received by Mapper#beforeCreate.DetailsType Since Source See Function 3.0.0 Container.js, line 41 Examplefunction onBeforeCreate (mapperName, props, opts) { // do something } store.on('beforeCreate', onBeforeCreate)
-
beforeCreateManyListener(name, records, opts)
-
Callback signature for the Container#event:beforeCreateMany event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeCreateMany.records
Object The
records
argument received by Mapper#beforeCreateMany.opts
Object The
opts
argument received by Mapper#beforeCreateMany.DetailsType Since Source See Function 3.0.0 Container.js, line 122 Examplefunction onBeforeCreateMany (mapperName, records, opts) { // do something } store.on('beforeCreateMany', onBeforeCreateMany)
-
beforeDestroyAllListener(name, query, opts)
-
Callback signature for the Container#event:beforeDestroyAll event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeDestroyAll.query
Object The
query
argument received by Mapper#beforeDestroyAll.opts
Object The
opts
argument received by Mapper#beforeDestroyAll.DetailsType Since Source See Function 3.0.0 Container.js, line 308 Examplefunction onBeforeDestroyAll (mapperName, query, opts) { // do something } store.on('beforeDestroyAll', onBeforeDestroyAll)
-
beforeDestroyListener(name, id, opts)
-
Callback signature for the Container#event:beforeDestroy event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeDestroy.id
String | Number The
id
argument received by Mapper#beforeDestroy.opts
Object The
opts
argument received by Mapper#beforeDestroy.DetailsType Since Source See Function 3.0.0 Container.js, line 230 Examplefunction onBeforeDestroy (mapperName, id, opts) { // do something } store.on('beforeDestroy', onBeforeDestroy)
-
beforeFindAllListener(name, query, opts)
-
Callback signature for the Container#event:beforeFindAll event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeFindAll.query
Object The
query
argument received by Mapper#beforeFindAll.opts
Object The
opts
argument received by Mapper#beforeFindAll.DetailsType Since Source See Function 3.0.0 Container.js, line 463 Examplefunction onBeforeFindAll (mapperName, query, opts) { // do something } store.on('beforeFindAll', onBeforeFindAll)
-
beforeFindListener(name, id, opts)
-
Callback signature for the Container#event:beforeFind event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeFind.id
String | Number The
id
argument received by Mapper#beforeFind.opts
Object The
opts
argument received by Mapper#beforeFind.DetailsType Since Source See Function 3.0.0 Container.js, line 386 Examplefunction onBeforeFind (mapperName, id, opts) { // do something } store.on('beforeFind', onBeforeFind)
-
beforeUpdateAllListener(name, props, query, opts)
-
Callback signature for the Container#event:beforeUpdateAll event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeUpdateAll.props
Object The
props
argument received by Mapper#beforeUpdateAll.query
Object The
query
argument received by Mapper#beforeUpdateAll.opts
Object The
opts
argument received by Mapper#beforeUpdateAll.DetailsType Since Source See Function 3.0.0 Container.js, line 713 Examplefunction onBeforeUpdateAll (mapperName, props, query, opts) { // do something } store.on('beforeUpdateAll', onBeforeUpdateAll)
-
beforeUpdateListener(name, id, props, opts)
-
Callback signature for the Container#event:beforeUpdate event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeUpdate.id
String | Number The
id
argument received by Mapper#beforeUpdate.props
Object The
props
argument received by Mapper#beforeUpdate.opts
Object The
opts
argument received by Mapper#beforeUpdate.DetailsType Since Source See Function 3.0.0 Container.js, line 629 Examplefunction onBeforeUpdate (mapperName, id, props, opts) { // do something } store.on('beforeUpdate', onBeforeUpdate)
-
beforeUpdateManyListener(name, records, opts)
-
Callback signature for the Container#event:beforeUpdateMany event.
Method parameters:Name Type Description name
String The
name
argument received by Mapper#beforeUpdateMany.records
Object The
records
argument received by Mapper#beforeUpdateMany.opts
Object The
opts
argument received by Mapper#beforeUpdateMany.DetailsType Since Source See Function 3.0.0 Container.js, line 796 Examplefunction onBeforeUpdateMany (mapperName, records, opts) { // do something } store.on('beforeUpdateMany', onBeforeUpdateMany)
Events
-
afterCreate
-
Fired during Container#create. See Container~afterCreateListener for how to listen for this event.
DetailsSource See Container.js, line 58 -
afterCreateMany
-
Fired during Container#createMany. See Container~afterCreateManyListener for how to listen for this event.
DetailsSource See Container.js, line 139 -
afterDestroy
-
Fired during Container#destroy. See Container~afterDestroyListener for how to listen for this event.
DetailsSource See Container.js, line 247 -
afterDestroyAll
-
Fired during Container#destroyAll. See Container~afterDestroyAllListener for how to listen for this event.
DetailsSource See Container.js, line 325 -
afterFind
-
Fired during Container#find. See Container~afterFindListener for how to listen for this event.
DetailsSource See Container.js, line 403 -
afterFindAll
-
Fired during Container#findAll. See Container~afterFindAllListener for how to listen for this event.
DetailsSource See Container.js, line 480 -
afterUpdate
-
Fired during Container#update. See Container~afterUpdateListener for how to listen for this event.
DetailsSource See Container.js, line 647 -
afterUpdateAll
-
Fired during Container#updateAll. See Container~afterUpdateAllListener for how to listen for this event.
DetailsSource See Container.js, line 731 -
afterUpdateMany
-
Fired during Container#updateMany. See Container~afterUpdateManyListener for how to listen for this event.
DetailsSource See Container.js, line 813 -
beforeCreate
-
Fired during Container#create. See Container~beforeCreateListener for how to listen for this event.
DetailsSource See Container.js, line 33 -
beforeCreateMany
-
Fired during Container#createMany. See Container~beforeCreateManyListener for how to listen for this event.
DetailsSource See Container.js, line 114 -
beforeDestroy
-
Fired during Container#destroy. See Container~beforeDestroyListener for how to listen for this event.
DetailsSource See Container.js, line 222 -
beforeDestroyAll
-
Fired during Container#destroyAll. See Container~beforeDestroyAllListener for how to listen for this event.
DetailsSource See Container.js, line 300 -
beforeFind
-
Fired during Container#find. See Container~beforeFindListener for how to listen for this event.
DetailsSource See Container.js, line 378 -
beforeFindAll
-
Fired during Container#findAll. See Container~beforeFindAllListener for how to listen for this event.
DetailsSource See Container.js, line 455 -
beforeUpdate
-
Fired during Container#update. See Container~beforeUpdateListener for how to listen for this event.
DetailsSource See Container.js, line 621 -
beforeUpdateAll
-
Fired during Container#updateAll. See Container~beforeUpdateAllListener for how to listen for this event.
DetailsSource See Container.js, line 705 -
beforeUpdateMany
-
Fired during Container#updateMany. See Container~beforeUpdateManyListener for how to listen for this event.
DetailsSource See Container.js, line 788