class MongooseModel[T] extends Object
Mongoose Model
- Annotations
- @RawJSType() @native()
- Alphabetic
- By Inheritance
- MongooseModel
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new MongooseModel(doc: Any, fields: Array[String] = js.native, skipId: Boolean = js.native)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
var
$where: Any
Additional properties to attach to the query when calling save() and isNew is false.
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
aggregate[A](pipeline: Any, callback: MongooseCallback[A]): Unit
Performs aggregations on the models collection.
Performs aggregations on the models collection.
- pipeline
aggregation pipeline operator(s) or operator array
- callback
the callback
aggregate([...], [callback])
Example: -
def
aggregate[A](pipeline: Any): Aggregate[A]
Performs aggregations on the models collection.
Performs aggregations on the models collection.
- pipeline
aggregation pipeline operator(s) or operator array
- returns
the Aggregate
aggregate([...], [callback])
Example: -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
base: String
Base Mongoose instance the model uses.
-
def
baseModelName: String
If this is a discriminator model, baseModelName is the name of the base model.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
collection: Any
Collection the model uses.
-
def
count(conditions: Any, callback: Function2[MongooseError, Int, Any]): Unit
Counts number of matching documents in a database collection.
Counts number of matching documents in a database collection.
- conditions
the given query/conditions
- callback
the callback
count(conditions, [callback])
Example: -
def
count(conditions: Any): Promise[Int]
Counts number of matching documents in a database collection.
Counts number of matching documents in a database collection.
- conditions
the given query/conditions
- returns
the promise of the count
count(conditions, [callback])
Example: -
def
create(docs: Array[T], callback: MongooseCallback[Array[T]]): Unit
Shortcut for saving one or more documents to the database.
Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs.
- docs
a document or array of documents
- callback
the callback
-
def
create(doc: T, callback: Function2[MongooseError, T, Any]): Unit
Shortcut for saving one or more documents to the database.
Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs.
- doc
a document or array of documents
- callback
the callback
-
def
create(docs: Array[T]): Promise[Array[T]]
Shortcut for saving one or more documents to the database.
Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs.
- docs
an array of documents to create
- returns
the created documents
-
def
create(doc: T): Promise[T]
Shortcut for saving one or more documents to the database.
Shortcut for saving one or more documents to the database. MyModel.create(docs) does new MyModel(doc).save() for every doc in docs.
- doc
a document to create
- returns
the created documents
-
def
db: Connection
Connection the model uses.
-
def
discriminator(name: String, schema: Schema[T]): Unit
Adds a discriminator type.
Adds a discriminator type.
- name
the discriminator model name
- schema
the discriminator model schema
-
def
discriminators: Any
Registered discriminators for this model.
-
def
distinct(field: String, callback: MongooseCallback[Array[T]]): Unit
Creates a Query for a distinct operation.
Creates a Query for a distinct operation.
- field
the field
- callback
the callback
-
def
distinct(field: String, conditions: Any, callback: MongooseCallback[Array[T]]): Unit
Creates a Query for a distinct operation.
Creates a Query for a distinct operation.
- field
the field
- conditions
the optional condition
- callback
the callback
-
def
distinct(field: String, conditions: Any = js.native): Query[Array[T]]
Creates a Query for a distinct operation.
Creates a Query for a distinct operation.
- field
the field
- conditions
the optional condition
- returns
the resulting query
- val doc: Any
-
def
ensureIndexes(options: RawOptions, calback: Function1[MongooseError, Any]): Unit
Sends ensureIndex commands to mongo for each index declared in the schema.
Sends ensureIndex commands to mongo for each index declared in the schema.
- options
the internal options
- calback
the optional callback
-
def
ensureIndexes(options: RawOptions): Promise[Unit]
Sends ensureIndex commands to mongo for each index declared in the schema.
Sends ensureIndex commands to mongo for each index declared in the schema.
- options
the internal options
- returns
a promise of the completion
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- val fields: Array[String]
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
find(conditions: Any, callback: MongooseModelArrayCallback[T]): Unit
Finds documents
Finds documents
- conditions
the given conditions/query
- callback
the optional callback
-
def
find(conditions: Any): Query[Array[Model[T]]]
Finds documents
Finds documents
- conditions
the given conditions/query
- returns
a Query
-
def
findById(id: |[|[ObjectId, String], Int], callback: MongooseModelCallback[T]): Unit
Finds a single document by its _id field.
Finds a single document by its _id field. findById(id) is almost* equivalent to findOne({ _id: id }). If you want to query by a document's _id, use findById() instead of findOne().
- id
the value of
_idto query by- callback
the optional callback
-
def
findById(id: |[|[ObjectId, String], Int], projection: RawOptions, callback: MongooseModelCallback[T]): Unit
Finds a single document by its _id field.
Finds a single document by its _id field. findById(id) is almost* equivalent to findOne({ _id: id }). If you want to query by a document's _id, use findById() instead of findOne().
- id
the value of
_idto query by- projection
the optional fields to return
- callback
the optional callback
-
def
findById(id: |[|[ObjectId, String], Int], projection: RawOptions = js.native): Query[Model[T]]
Finds a single document by its _id field.
Finds a single document by its _id field. findById(id) is almost* equivalent to findOne({ _id: id }). If you want to query by a document's _id, use findById() instead of findOne().
- id
the value of
_idto query by- projection
the optional fields to return
- returns
the Query
-
def
findByIdAndRemove(id: |[|[ObjectId, String], Int], callback: MongooseModelCallback[T]): Unit
Issue a mongodb findAndModify remove command by a document's _id field.
Issue a mongodb findAndModify remove command by a document's _id field. findByIdAndRemove(id, ...) is equivalent to findOneAndRemove({ _id: id }, ...).
- id
the value of
_idto query by- callback
the optional callback
findByIdAndRemove(id, [options], [callback])
Example: -
def
findByIdAndRemove(id: |[|[ObjectId, String], Int], options: RawOptions, callback: MongooseModelCallback[T]): Unit
Issue a mongodb findAndModify remove command by a document's _id field.
Issue a mongodb findAndModify remove command by a document's _id field. findByIdAndRemove(id, ...) is equivalent to findOneAndRemove({ _id: id }, ...).
- id
the value of
_idto query by- options
the optional options
- callback
the optional callback
findByIdAndRemove(id, [options], [callback])
Example: -
def
findByIdAndRemove(id: |[|[ObjectId, String], Int], options: RawOptions = js.native): Promise[Model[T]]
Issue a mongodb findAndModify remove command by a document's _id field.
Issue a mongodb findAndModify remove command by a document's _id field. findByIdAndRemove(id, ...) is equivalent to findOneAndRemove({ _id: id }, ...).
- id
the value of
_idto query by- options
the optional options
- returns
a promise of the results
findByIdAndRemove(id, [options], [callback])
Example: -
def
findByIdAndUpdate(id: |[|[ObjectId, String], Int], update: Any, options: RawOptions, callback: MongooseModelCallback[T]): Unit
Issues a mongodb findAndModify update command by a document's _id field.
Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...) is equivalent to findOneAndUpdate({ _id: id }, ...).
- id
the value of
_idto query by- update
the update sub-document
- options
the optional options
- callback
the optional callback
-
def
findByIdAndUpdate(id: |[|[ObjectId, String], Int], update: Any, callback: MongooseModelCallback[T]): Unit
Issues a mongodb findAndModify update command by a document's _id field.
Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...) is equivalent to findOneAndUpdate({ _id: id }, ...).
- id
the value of
_idto query by- update
the update sub-document
- callback
the optional callback
-
def
findByIdAndUpdate(id: |[|[ObjectId, String], Int], update: Any, options: RawOptions = js.native): Promise[Model[T]]
Issues a mongodb findAndModify update command by a document's _id field.
Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...) is equivalent to findOneAndUpdate({ _id: id }, ...).
- id
the value of
_idto query by- update
the update sub-document
- options
the optional options
- returns
the promise of the document
-
def
findOne(conditions: Any, projection: Any, callback: MongooseModelCallback[T]): Unit
Finds one document.
Finds one document.
- conditions
the conditions/query
- projection
the optional fields to return
- callback
the option callback
-
def
findOne(conditions: Any, callback: MongooseModelCallback[T]): Unit
Finds one document.
Finds one document.
- conditions
the conditions/query
- callback
the option callback
-
def
findOne(conditions: Any, projection: Any = js.native): Query[Model[T]]
Finds one document.
Finds one document.
- conditions
the conditions/query
- projection
the optional fields to return
- returns
the Query
-
def
findOneAndRemove(conditions: Any, callback: MongooseModelCallback[T]): Unit
Issue a mongodb findAndModify remove command.
Issue a mongodb findAndModify remove command.
- conditions
the conditions/query
- callback
the option callback
-
def
findOneAndRemove(conditions: Any, options: RawOptions, callback: MongooseModelCallback[T]): Unit
Issue a mongodb findAndModify remove command.
Issue a mongodb findAndModify remove command.
- conditions
the conditions/query
- options
the optional options
- callback
the option callback
-
def
findOneAndRemove(conditions: Any, options: RawOptions = js.native): Promise[Model[T]]
Issue a mongodb findAndModify remove command.
Issue a mongodb findAndModify remove command.
- conditions
the conditions/query
- options
the optional options
- returns
the promise of the removed document
-
def
findOneAndUpdate(conditions: Any, update: Any, callback: MongooseModelCallback[T]): Unit
Issues a mongodb findAndModify update command.
Issues a mongodb findAndModify update command.
- conditions
the conditions/query
- update
the sub-document update
- callback
the option callback
-
def
findOneAndUpdate(conditions: Any, update: Any, options: RawOptions, callback: MongooseModelCallback[T]): Unit
Issues a mongodb findAndModify update command.
Issues a mongodb findAndModify update command.
- conditions
the conditions/query
- update
the sub-document update
- options
the optional options
- callback
the option callback
-
def
findOneAndUpdate(conditions: Any, update: Any, options: RawOptions = js.native): Promise[Model[T]]
Issues a mongodb findAndModify update command.
Issues a mongodb findAndModify update command.
- conditions
the conditions/query
- update
the sub-document update
- options
the optional options
- returns
the promise of the updated document
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
insertMany(docs: Array[T], callback: MongooseModelArrayCallback[T]): Unit
Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid.
Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid. This function is faster than .create() because it only sends one operation to the server, rather than one for each document.
- docs
the documents to insert
- callback
the option callback
-
def
insertMany(docs: Array[T], options: RawOptions, callback: MongooseModelArrayCallback[T]): Unit
Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid.
Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid. This function is faster than .create() because it only sends one operation to the server, rather than one for each document.
- docs
the documents to insert
- options
the optional options
- callback
the option callback
-
def
insertMany(docs: Array[T], options: RawOptions = js.native): Promise[Array[Model[T]]]
Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid.
Shortcut for validating an array of documents and inserting them into MongoDB if they're all valid. This function is faster than .create() because it only sends one operation to the server, rather than one for each document.
- docs
the documents to insert
- options
the optional options
- returns
a promise of the inserted documents
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
-
def
mapReduce[A](obj: Any, callback: Function2[MongooseError, A, T]): Unit
Executes a mapReduce command.
Executes a mapReduce command.
- obj
an object specifying map-reduce options
- callback
the optional callback
-
def
mapReduce[A](obj: Any): Promise[A]
Executes a mapReduce command.
Executes a mapReduce command.
- obj
an object specifying map-reduce options
- returns
the promise of the results
-
def
model[A](name: String): MongooseModel[A]
Returns another Model instance.
Returns another Model instance.
- A
the model type
- name
the model name
- returns
the model
-
def
modelName: String
The name of the model
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
populate(docs: Array[T], options: Dictionary[Any], callback: MongooseModelCallback[T]): Unit
Populates document references.
Populates document references.
- docs
Either a single document or array of documents to populate.
- options
A hash of key/val (path, options) used for population.
- callback
Optional callback, executed upon completion. Receives
errand thedoc(s).
-
def
populate(docs: Array[T], options: Dictionary[Any]): Promise[Array[Model[T]]]
Populates document references.
Populates document references.
- docs
an array of documents to populate.
- options
A hash of key/val (path, options) used for population.
- returns
the
doc(s).
-
def
populate(docs: T, options: Dictionary[Any], callback: MongooseModelCallback[T]): Unit
Populates document references.
Populates document references.
- docs
Either a single document or array of documents to populate.
- options
A hash of key/val (path, options) used for population.
- callback
Optional callback, executed upon completion. Receives
errand thedoc(s).
-
def
populate(doc: T, options: Dictionary[Any]): Promise[Model[T]]
Populates document references.
Populates document references.
- doc
a single document to populate.
- options
A hash of key/val (path, options) used for population.
- returns
the
doc(s).
-
def
propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
-
def
remove(conditions: Any, callback: Function2[MongooseError, UpdateWriteResult, Any]): Unit
Removes documents from the collection.
Removes documents from the collection.
- conditions
the conditions/query
- callback
the optional callback
-
def
remove(conditions: Any): Promise[UpdateWriteResult]
Removes documents from the collection.
Removes documents from the collection.
- conditions
the conditions/query
- returns
the promise of the removed document
-
def
schema: Schema[T]
The Schema the model uses.
- val skipId: Boolean
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toLocaleString(): String
- Definition Classes
- Object
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
update(conditions: Any, doc: Any, callback: MongooseModelArrayCallback[T]): Unit
Updates documents in the database without returning them.
Updates documents in the database without returning them.
- conditions
the conditions/query
- doc
the sub-document to use in the update
- callback
the optional callback
-
def
update(conditions: Any, doc: Any, options: RawOptions, callback: MongooseModelArrayCallback[T]): Unit
Updates documents in the database without returning them.
Updates documents in the database without returning them.
- conditions
the conditions/query
- doc
the sub-document to use in the update
- options
the optional options
- callback
the optional callback
-
def
update(conditions: Any, doc: Any, options: RawOptions = js.native): Promise[Array[Model[T]]]
Updates documents in the database without returning them.
Updates documents in the database without returning them.
- doc
the sub-document to use in the update
- options
the optional options
- returns
the promise of the updated document
-
def
updateMany(conditions: Any, doc: Any, callback: MongooseModelArrayCallback[T]): Unit
Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.
Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.
- conditions
the conditions/query
- doc
the sub-document to use in the update
- callback
the optional callback
-
def
updateMany(conditions: Any, doc: Any, options: RawOptions, callback: MongooseModelArrayCallback[T]): Unit
Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.
Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.
- conditions
the conditions/query
- doc
the sub-document to use in the update
- options
the optional options
- callback
the optional callback
-
def
updateMany(conditions: Any, doc: Any, options: RawOptions = js.native): Promise[Array[Model[T]]]
Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.
Same as update(), except MongoDB will update all documents that match criteria (as opposed to just the first one) regardless of the value of the multi option.
- doc
the sub-document to use in the update
- options
the optional options
- returns
the promise of the updated document
-
def
updateOne(conditions: Any, doc: Any, callback: MongooseModelCallback[T]): Unit
Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.
Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.
- conditions
the conditions/query
- doc
the sub-document to use in the update
- callback
the optional callback
-
def
updateOne(conditions: Any, doc: Any, options: RawOptions, callback: MongooseModelCallback[T]): Unit
Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.
Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.
- conditions
the conditions/query
- doc
the sub-document to use in the update
- options
the optional options
- callback
the optional callback
-
def
updateOne(conditions: Any, doc: Any, options: RawOptions = js.native): Promise[Model[T]]
Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.
Same as update(), except MongoDB will update only the first document that matches criteria regardless of the value of the multi option.
- conditions
the conditions/query
- doc
the sub-document to use in the update
- options
the optional options
- returns
the promise of the updated document
-
def
valueOf(): Any
- Definition Classes
- Object
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
where(path: String, value: Any = js.native): QueryOperator[Array[T]]
Creates a Query, applies the passed conditions, and returns the Query.
Creates a Query, applies the passed conditions, and returns the Query.
- path
the given path/field
- value
the optional value
- returns
the QueryOperator