Model methods:
create
: creates a new document and saves it to the databasefindById
: finds a document by its IDfindByIdAndUpdate
: finds a document by its ID and updates itfindByIdAndDelete
: finds a document by its ID and deletes itfindOne
: finds a single document that matches the query criteriafindOneAndUpdate
: finds a single document that matches the query criteria and updates itfindOneAndDelete
: finds a single document that matches the query criteria and deletes itupdateOne
: updates a single document that matches the query criteriaupdateMany
: updates all documents that match the query criteriadeleteOne
: deletes a single document that matches the query criteriadeleteMany
: deletes all documents that match the query criteriacountDocuments
: counts the number of documents that match the query criteriaQuery methods:
where
: specifies a query conditionequals
: specifies an exact match query conditiongt
: specifies a greater than query conditiongte
: specifies a greater than or equal to query conditionlt
: specifies a less than query conditionlte
: specifies a less than or equal to query conditionin
: specifies an inclusion query conditionnin
: specifies an exclusion query conditionlimit
: limits the number of documents returnedskip
: skips a specified number of documentssort
: sorts the documents based on the specified criteriaselect
: specifies the fields to include or exclude in the query resultspopulate
: populates the referenced documents in a document or documentsexec
: executes the queryDocument methods:
save
: saves the document to the databaseupdate
: updates the document in the databaseremove
: removes the document from the databaseset
: sets the value of a document fieldget
: gets the value of a document fieldvalidate
: validates the document against the schemaSchema methods:
pre
: specifies middleware functions to execute before a certain event occurspost
: specifies middleware functions to execute after a certain event occursvirtual
: creates a virtual property that is not stored in the databasestatic
: adds a static method to the model that can be called directly on the model