A NodeJS mongoose Schema Example

Introduction In this tutorial we hope to show a NodeJS with mongoose schema example as a starting point for developers setting up this type of architecture. MongoDB is one of the most popular NoSQL databases around. It is fairly easy to use and understand when compared with SQL databases. But it is a schemaless database. … Continued

How to use Node JS and mongodb to Query Count

Introduction In this article we’ll be covering how to find the number of documents of a MongoDB collection. Specifically we will be using Node JS and MongoDB to query the count of a collection. There can be multiple MongoDB databases. Each database can contain several collections and each of these collections can contain hundreds of … Continued

Using nodejs and mongoose to update array

Introduction Working with arrays can be complicated. Updating can be more complicated. One should work carefully while performing update operations on arrays. Mongoose provides a few operators to update arrays such as $addToSet, $push, $pop, etc. In this article, we will discuss how to use such operators to perform update operations on arrays in nodejs. … Continued

$all in mongoose

Introduction Arrays are one of the most commonly used data structures in the programming world. They are perfect to store elements of the same data types. We can store any type of data in arrays. While working with databases, we may need to store data in an array. For example, the following MongoDB documents contain … Continued

Push and pop in mongoose

Introduction Arrays are one of the most commonly used data structures in the programming world. They are perfect to store elements of the same data types. We can store any type of data in arrays. While working with databases, we may need to store data in an array. For example, the following MongoDB documents contain … Continued

and in mongoose

Introduction Every Mongoose method has a query part. The query consists of conditions according to which the documents will be matched. The query can be simple and it can be complicated as well. Observe the following query. 1{ "breed" : "Labrador" } The above query will match all the documents where the value of the … Continued

How to use mongoose with Node

Introduction Node.js and MongoDB are part of MEAN and MERN stack. The pair is heavily used while building backends for web applications. MongoDB is a NoSQL database and it is quite popular for its simplicity. It is very simple to install and implement. With Node.js, we can easily perform various operations on MongoDB databases. These … Continued

How to use the mongoose $lte operator

Introduction In this article we’ll be discussing the mongoose $lte operator, what it does, and how to use it with a simple demonstration. Mongoose provides several methods that can be used while performing CRUD operations. In most cases, we have to provide a query to get the desired results. A query is specified inside curly … Continued

How to use the mongoose findOneAndReplace function

Introduction Mongoose provides a few methods for replacing documents in a collection. One of these methods is findOneAndReplace(). This method finds a document according to the query and then replaces it with another document. It is quite similar to the replaceOne() method. But there is a difference in options. In both of these methods, we … Continued

How to use the mongoose $gte operator

Introduction A query is an important part of CRUD operations. In most cases, we have to provide a query to get the desired results. A query is specified inside curly brackets. The complexity of a query depends upon the requirements. It can be simple and it can be complicated as well. For example, if we … Continued

Keep in the know!

Subscribe to our emails and we’ll let you know what’s going on at ObjectRocket. We hate spam and make it easy to unsubscribe.