Mongoose Document Model.count() API
The Model.count() method of the Mongoose API is used to count the number of documents present in the collection based on the given filter condition. It returns the query object and count of documents present in the collection....
read more
Mongoose Document Model.bulkWrite() API
The Model.bulkWrite() method of the Mongoose API is used to perform multiple operations in one command. It can insert multiple documents, can update one or multiple documents, can replace documents, can delete documents in one single command. This is faster in performance than multiple independent create commands....
read more
Mongoose Document Model.exists() API
The Model.exists() method of the Mongoose API is used to find documents in the database. This method returns a document with “_id” if at least one document is present in the database that matches the given filter condition....
read more
Mongoose Document Model.insertMany() API
The Model.insertMany() method of the Mongoose API is used to insert more than one document in the collection at a time in one go. We can provide an array of objects to the insertMany() and can be executed on the model object. Mongoose validates all the objects in the array and if any object has a validation error no object or document will get inserted....
read more
Mongoose Document Model.deleteOne() API
The Model.deleteOne() method of the Mongoose API is used to delete a document from the collection. We can provide an object of the field to the deleteOne() and can be executed on the model object. It will delete the first document that matches the condition from the collection....
read more
Mongoose Document Model.deleteMany() API
The Model.deleteMany() method of the Mongoose API is used to delete more than one document in the collection at a time in one go. We can provide an object which contains a condition to the deleteMany() and can be executed on the model object. It will delete all the documents from the collection that will match the given condition....
read more
Mongoose Document Model.remove() API
The Model.remove() method of the Mongoose API is used to remove all the documents present in the collection in one go. It will be called on a Collection model which is already defined and present in the database....
read more
Mongoose Document Model.init() API
The Model.init() method of Mongoose API is responsible for building indexes. Although, Mongoose calls this function automatically when a model is created using mongoose.model() or connection.model()....
read more
Mongoose Document Model.replaceOne() API
The Model.replaceOne() method of the Mongoose API is used to replace any one document in a collection. This method works the same as the update method but it replaces MongoDB’s existing document with the given document with any atomic operator i.e $set....
read more
Mongoose Document Model.prototype.deleteOne() API
The Model.prototype.deleteOne() method of the Mongoose API is used to delete any one document in a collection. This method deletes the first document that matches the condition provided to the method as a first parameter....
read more
Mongoose Document Model.where() API
The Model.where() method of the Mongoose API is used to extract documents from a collection based on conditions. We can directly use where() on any model and on where() we can put various relational conditions to get the result. Model.where() returns array of objects. Each object consists of the document in a collection....
read more
Mongoose Document Model.inspect() API
The Model.inspect() method of the Mongoose API is used to get the model’s name in the database. This method works on any model object which is defined using mongoose....
read more