Model Class
Description
The model constructor.
Constructor
Model
(name, schema, database)Methods
_applyGetter
(obj, name, value, [prefix]) Object private_applySetter
(obj, name, value, [prefix]) Object private_createQuery
([index]) Query private_save
(obj, callback) private_updateIndex
privateUpdates the index.
destroy
chainableDeletes all documents in the model.
find
(conditions, [options]) Queryinsert
(obj, [callback]) chainablereduce
(callback, [initial]) AnyReduces a collection to a value which is the accumulated result of iterating each element in the collection.
Parameters
- callback Function
-
initial
Any
optional
Initial value
Returns
- Any
reduceRight
(callback, [initial]) AnyReduces a collection to a value which is the accumulated result of iterating each element in the collection from right to left.
Parameters
- callback Function
-
initial
Any
optional
Initial value
Returns
- Any
remove
(conditions, [callback]) chainableremoveById
(id, [callback]) chainablereplace
(conditions, obj, [callback]) chainablereplaceById
(id, obj, [callback]) chainablesave
(obj, [callback]) chainableupdate
(conditions, obj, [callback]) chainableupdateById
(id, obj, [callback]) chainableProperties
_database
privateThe reference to the database.
_doc
privateThe document constructor.
_index
privateThe index of the model.
_name
privateThe name of the model.
_query
privateThe query constructor.
_store
privateReference the store in the database as lazy-loaded getter.
length
Returns the number of items in the model.
schema
privateThe schema of the model.
Events
init
Fires when the model initialized.