Document instance are created from a model.
- Static Methods
isClean() => Boolean
true is the document has been modified since being fetched from the database.
If the document is new,
isClean will return
isSaved() => Boolean
true is the document is already saved in the database.
isPopulated(field: String) => Boolean
true if the field has been populated during a query or using
set(property: String, value: Mixed) => Document
Returns a new Document also containing the updated key, value pair.
merge(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() => Promise<Document>
Saves this document. it commits the document to the MongoDB collection.
remove() => Promise
Removes this document from the database.
compareWith(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() => Promise<Document>
Validate the document values, it returns the new document with validated values or a rejected promise.
populate(fields: String|Map<String, Options>|List<String>) => Promise<Document>
Populates document references.
See Populating references for details.
toMongo() => Object
toValues() => Map
Return all values in this document as an immutable map.
find(conditions: Object) => Query
Finds matching documents in a database collection.
count(conditions: Object) => Query
Counts number of matching documents in a database collection.
discriminate(conditions: Object) => Model
Create a new document model by discriminating the current one.