Document
Document instance are created from a model.
Methods
isClean
isCleanisClean() => Boolean
Returns true is the document has been modified since being fetched from the database.
If the document is new, isClean will return false.
isSaved
isSavedisSaved() => Boolean
Return true is the document is already saved in the database.
isPopulated
isPopulatedisPopulated(field: String) => Boolean
Return true if the field has been populated during a query or using .populate.
set
setset(property: String, value: Mixed) => Document
Returns a new Document also containing the updated key, value pair.
merge
mergemerge(properties: Object|Map) => Document
Returns a new Document resulting from merging the provided Iterables (or JS objects) into this Document. In other words, this takes each entry of each iterable and sets it on this Document.
save
savesave() => Promise<Document>
Saves this document. it commits the document to the MongoDB collection.
remove
removeremove() => Promise
Removes this document from the database.
compareWith
compareWithcompareWith(other: Document) => List<Change>
Compare this document with another one. It returns all changes required to go from this document to another one.
See Changes for details.
validate
validatevalidate() => Promise<Document>
Validate the document values, it returns the new document with validated values or a rejected promise.
populate
populatepopulate(fields: String|Map<String, Options>|List<String>) => Promise<Document>
Populates document references.
See Populating references for details.
toMongo
toMongotoMongo() => Object
Return the document as a plain JavaScript object, similar to what is being stored on Mongo.
toValues
toValuestoValues() => Map
Return all values in this document as an immutable map.
Static Methods
find
findfind(conditions: Object) => Query
Finds matching documents in a database collection.
count
countcount(conditions: Object) => Query
Counts number of matching documents in a database collection.
discriminate
discriminatediscriminate(conditions: Object) => Model
Create a new document model by discriminating the current one.
Last updated
Was this helpful?