MongoDB

MongoDB

MongoDB find documents within two dates

We have one collection with the below documents :.

Read
MongoDB

MongoDB find() method introduction

The find() method in MongoDB is used to search documents in a collection. You can get all the documents in a collection using this method based on the condition that you are providing. It takes two optional parameters :.

Read
MongoDB

How to update one or multiple documents in MongoDB

If you have one database, you need one method to update its data. MongoDB provides one really easy update method to update one single or multiple documents. You can also update only one value of a document. In this tutorial, I will show you two different examples to update one single or multiple documents using the update method. Note that this method works on the mongo shell. If you are using any other libraries in your project, the documentation may differ.

Read
MongoDB

How to sort documents in MongoDB

We can easily sort the documents before retrieving them from a collection in MongoDB. Sorting is one of the important functionality that we should be aware of. In this tutorial, I will show you how to sort documents with a query.

Read
MongoDB

How to use skip() method in MongoDB

In MongoDB, we can limit the number of documents that we want by using limit() method. This method takes one number and returns only that number of documents. Similar to limit(), we also have another method called skip() to skip the starting values. This method is defined as below :.

Read
MongoDB

How to use limit method in MongoDB with examples

In this tutorial, we will learn how to use the limit() method in MongoDB with different examples. limit() method is used to fetch only a specific number of documents. This method takes one number, i.e. the number of documents that you want to fetch. You can use it on find().

Read
MongoDB

How to change the port of a mongod instance

Sometimes you may need to change the port of mongod instance running in your system. The default port is 27017 and it is used by default if you are running mongod. This port is used by both mongod and mongos instance.

Read
MongoDB

How to dump and restore mongodb data from cloud.mongodb easily

I was looking for an easy way to dump and restore MongoDB data from my cloud.mongodb cluster free tier plan. Actually, I am running a couple of side projects on cloud.mongodb and the free plan is enough for the current traffic.

Read
MongoDB

Backup and restore MongoDB using mongodump and mongorestore

Database backup is always required either you are developing an application or it is running on production. In this blog post, I will show you how to take the backup of a mongodb database using mongodump and how to restore that database using mongorestore.

Read
MongoDB

pretty() method in MongoDB

pretty() method is used mainly to display the result in a more easy-to-read format. In this tutorial, I will show you how to use pretty() method and how the data looks with and without using pretty() and how the data looks like. The syntax of pretty() method is as below :.

Read