DocumentArray
MongooseDocumentArray.prototype.create()
MongooseDocumentArray.prototype.id()
MongooseDocumentArray.prototype.inspect()
MongooseDocumentArray.prototype.pull()
MongooseDocumentArray.prototype.push()
MongooseDocumentArray.prototype.toObject()
MongooseDocumentArray.prototype.create()
Parameters:
obj
«Object» the value to cast to this arrays SubDocument schema
Creates a subdocument casted to this schema.
This is the same subdocument constructor used for casting.
MongooseDocumentArray.prototype.id()
Parameters:
id
«ObjectId|String|Number|Buffer»
Returns:
- «EmbeddedDocument,null» the subdocument or null if not found.
Searches array items for the first document with a matching _id.
Example:
const embeddedDoc = m.array.id(some_id);
MongooseDocumentArray.prototype.inspect()
Helper for console.log
MongooseDocumentArray.prototype.pull()
Parameters:
[...args]
«Object»
Pulls items from the array atomically.
MongooseDocumentArray.prototype.push()
Parameters:
[...args]
«Object»
Wraps Array#push
with proper change tracking.
MongooseDocumentArray.prototype.toObject()
Parameters:
[options]
«Object» optional options to pass to each documentstoObject
method call during conversion
Returns:
- «Array»
Returns a native js Array of plain js objects
Note:
Each sub-document is converted to a plain object by calling its #toObject
method.