Mongoose Aggregate.prototype.sort() API
The Aggregate sort() method of the Mongoose API is used to perform aggregation tasks. It allows us to sort all the documents in a collection based on the fields that we provide. It also provides us the flexibility to sort the input documents in ascending or descending order....
read more
Mongoose Model.aggregate() API
The Mongoose Model API Model.aggregate() method of the Mongoose API is used on the Document model. It allows to perform aggregation tasks on the models collection. Using this method we can execute aggregation operation on mongoose models. We can directly call this method on model. Let us understand the aggregate() method using an example....
read more
How to add range in the Collection of Mongodb using Node.js ?
Mongoose.module is one of the most powerful external module of the node.js.Mongoose is a MongoDB ODM i.e (Object database Modelling) that used to translate the code and its representation from MongoDB to the Node.js server.Mongoose module provides several functions in order to manipulate the documents of the collection of the MongoDB database (Refer this Link)...
read more
Mongoose Queries Model.findOneAndUpdate() Function
The Queries Model.findOneAndUpdate() function of the Mongoose API is used to find and update an existing document with the information mentioned in the “update” object. It finds and updates only the first document that is returned in the filter....
read more
Mongoose Plugins
Plugins are a technique for reusing logic in multiple mongoose schemas. A plugin is similar to a method that you can use in your schema and reuse repeatedly over different instances of the schema. The main purpose of plugins is to modify your schemas. Plugins don’t have anything to do with models or documents, so they can’t execute queries or write to the database directly. A mongoose plugin is a JavaScript method that takes two parameters: the Schema, and an optional Options object....
read more
What is Connection Pooling with MongoDB in Node.js ?
In this article, we are going to see in-depth connection pools MongoDB in Nodejs. A connection pool serves as a collection of established TCP connections that your application’s MongoDB driver maintains with a MongoDB server. This pool’s purpose is to minimize the need for frequent network handshakes, ultimately enhancing your application’s performance by reducing connection setup overhead....
read more
How to replace one document in MongoDB using Node.js ?
MongoDB, the most popular NoSQL database, we can count the number of documents in MongoDB Collection using the MongoDB collection.countDocuments() function. The mongodb module is used for connecting the MongoDB database as well as used for manipulating the collections and databases in MongoDB....
read more
How to set the document value type in MongoDB using Node.js?
Mongoose.module is one of the most powerful external module of the node.js. Mongoose is a MongoDB ODM i.e (Object database Modelling) that used to translate the code and its representation from MongoDB to the Node.js server. Mongoose module provides several functions in order to manipulate the documents of the collection of the MongoDB database (Refer this Link)....
read more
Mongoose Schema Connection.prototype.useDb() API
The Connection.prototype.useDb() method of the Mongoose API is used on the Connection object. It allows us to change the current working database. It is used to switch between databases using the same connection pool. Let us understand useDb() method using an example....
read more
Mongoose SchemaTypes schema.path() Function
The Mongoose SchemaTypes schema.path() function is used to get the instantiated schema type for a given path. This function can be used to inspect the schema type and validator for a given path....
read more
Mongoose Schema.prototype.static() API
The Mongoose Schema API.prototype.static() method of the Mongoose API is used on the Schema object. It allows us to define static class methods for the models using schema objects. We can access static method on schema object to define static methods. Let us understand static() method using an example....
read more
Pagination on an API
MongoDB is an efficient NoSQL database. It is used across the software industry to a great extent as it is open source, easily configurable, maintenance wise it is easier, upgradation wise, portability wise it plays a major role and hence it is a more like NoSQL database....
read more