How to use the ODM mongoose with your db

Introduction MongoDB is one of the most popular NoSQL databases. It stores data in BSON format (an extension of JSON). It is faster than SQL databases and handles unstructured data very efficiently. MongoDB is often used with NodeJS. Node.js is a javascript runtime environment that executes javascript outside the browser. Both MongoDB and Node.js are … Continued

Easy to follow mongoose example with NodeJS

Introduction In this article, we will discuss an easy to following mongoose example with NodeJS. We will create four API endpoints in NodeJS and mongoose, each of them performing certain CRUD operations on a MongoDB database. Setup connection So let’s start by setting up a server and a connection with the MongoDB database. 123456789101112131415161718var mongoose … Continued

mongoose replaceOne

Introduction The CRUD update operation is one that should be handled with the utmost care. The update operation modifies the data in a database. Even a small mistake can create many problems. So, the update operations should be performed carefully. Data in MongoDB can be updated using various methods. There are several methods that are … Continued

The mongoose exists function

Introduction There are typically large amounts of documents in a MongoDB collection. There are occasions when you want to check if a document exists, often before performing a second operation if it does. For that occasion mongoose provided the very handy exists() method. In this article, we will discuss the mongoose exists() method and how … Continued

Or in mongoose

Introduction In this article we will talk about how to use the OR operator in our mongoose queries. The or operator is the counterpart to the and operator and is essential knowledge when working with database queries. We’ll specifically show you how to use within mongoose. Please continue reading to learn how to use or … Continued

Simple mongoose and node js Example

In this article, we will create a simple mongoose and Node Js example with step by step instructions. Please review the prerequisites below. Prerequisites – NodeJs and MongoDB installed. Knowledge of javascript. Nodemon installed. So let’s start. Install express with npm First of all, we need a package.json file to start with. Create a new … Continued

Inserting data into MongoDB using post in mongoose

CRUD operations As we all know, a database is used to store data. But it’s not just that. We always don’t have static data. After setting up a database, we may need to perform many operations. We may need to add more data, or we need all the data or some data. We may also … Continued

How to install mongoose with npm

Introduction Mongoose is an Object Data Modeling (ODM) library that is used for schema validations and managing relationships among data. Mongoose is frequently used with NodeJS and MongoDB. Understanding mongoose is very important and it is also very simple at the same time. But before we can use mongoose in our NodeJS files, we need … Continued

Understanding the mongoose __v field

Introduction Data in MongoDB is stored in JSON format. More precisely said, data is stored in BSON format. BSON format provides a variety of data types. We can insert data from mongo shell or through mongoose. In both cases, the _id field is generated automatically in each document. The _id field acts as a primary … Continued

How to use express with mongoose

Introduction Express is an important part of web application development stacks such as MEAN and MERN stack. Developing web applications is not an easy task. Backend is an important part of every web application. The backend is the connectivity to databases and it also holds APIs that interact with the databases. One important part of … 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.