MongoDB

MongoDB

MongoDB : Insert one single document to a collection

For inserting one document to a collection in MongoDB, we can use insertOne() method. It has the following syntax :.

Read
MongoDB

Insert multiple documents to a MongoDB collection using insertMany

insertMany() was introduced in MongoDB version 3.2. Using this method, we can insert multiple documents to a collection easily. It has the below syntax :.

Read
MongoDB

How to drop a collection in MongoDB

Dropping a collection will remove it from the database. It will also remove any index associated with the dropped collection. It also removes all indexes associated with the dropped collection. This method will obtain a write lock on the database. It will block all other operations till the drop is completed.

Read
MongoDB

How to check the type of a field in Mongo shell

We can check the type of a field using Mongo shell. In this quick tutorial, I will show you how to do that.MongoDB provides two different operators for type checking. MongoDB provides two different operators for type checking- instanceof and typeof. Using these operators, we can either check if a field is of a certain type or we can check the type of a field. Let me show with two examples to make this more clear.

Read
MongoDB

How to create a simple and capped collection in MongoDB

Collections are used to group MongoDB documents. If you are familier with RDBMS, you can think it like a table. Collections are created within a database. Again, documents are created within collection. These documents contains different different fields with different data.In this tutorial, we will show you how to create a collection with different ways to create different types of collection.

Read
MongoDB

MongoDB tutorial : How to drop a database in MongoDB

Drop a database means deleting a database. If you drop a database, it will remove everything inside it.In this tutorial, we will show you how to drop a database in MongoDB.

Read
MongoDB

How to create a database in MongoDB and insert data

Database is used in MongoDB to store all different types of collections and each collection stores documents. We will come to this later, but before that let's learn how to create a database and how to move between databases.

Read