Native MongoDB driver for Node.js
The native MongoDB driver for Node.JS is a dependency that allows our JavaScript application to interact with the NoSQL database, either locally or on the cloud through MongoDB Atlas. We are allowed to use promises as well as callbacks that gives us greater flexibility in using ES6 features....
read more
Mongoose | estimatedDocumentCount() Function
The estimatedDocumentCount() function is quick as it estimates the number of documents in the MongoDB collection. It is used for large collections because this function uses collection metadata rather than scanning the entire collection....
read more
How to count total number of documents in MongoDB Collection 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
Mongoose Aggregate Aggregate() API
The Mongoose Aggregate API Aggregate() method of the Mongoose API is used to perform aggregation tasks. It allows us to create an aggregation pipeline. The aggregation constructor is used for building and configuring aggregation pipeline. It is recommended not to instantiate the Aggregation class directly instead we can use it on any model we have defined over mongoose schema. Let us understand the aggregate() method using an example....
read more
Mongoose Connection String Options
Mongoose is a JavaScript library that provides a convenient way to interact with MongoDB databases. In order to use Mongoose, you need to create a connection between your Node.js application and the MongoDB server. The Mongoose connection represents this connection and provides a number of useful features, such as connection pooling and events for monitoring the connection status....
read more
Feedback form using Pugjs, Node.js, MongoDB, Express
We can create a feedback form using PugJs, NodeJS, MongoDB, Express with the following steps. A feedback form takes the input from the user and sends the data to the server to process it and store it accordingly into the database....
read more
Mongoose Queries Model.updateOne() Function
The Queries Model.updateOne() function of the Mongoose API is used to update an existing document with the information mentioned in the “update” object. It updates only the first document that is returned in the filter....
read more
Mongoose Document API
Mongoose documents correspond to MongoDB documents in a one-to-one relationship. A mongoose document is basically an instance of a model....
read more
Mongoose Document.prototype.toJSON() API
The Mongoose Document API.prototype.toJSON() method of the Mongoose API is used on the Document model. It allows to convert the result set into JSON object. The converted JSON object then can be used as a parameter to the JSON.stringify() method. Let us understand the toJSON() method using an example....
read more
How to add Timestamp in Mongodb Collection using Node.js ?
Timestamp: With the help of timestamp document in the collection of the MongoDB can be differentiated on the basis of time. We can add Timestamp in Mongodb Collection in Node.js using the following approach:...
read more
How to create new Collection in MongoDB using Node.js ?
MongoDB the most popular NoSQL database, is an open-source document-oriented database. The term ‘NoSQL’ means ‘non-relational’. It means that MongoDB isn’t based on the table-like relational database structure but provides an altogether different mechanism for storage and retrieval of data. This format of storage is called BSON (similar to JSON format). Refer (this) article....
read more
Defining, Creating and Dropping a MongoDB collection
MongoDB, the most popular NoSQL database, is an open-source document-oriented database. The term ‘NoSQL’ means ‘non-relational’. It means that MongoDB isn’t based on the table-like relational database structure but provides an altogether different mechanism for storage and retrieval of data....
read more