MongoDB Basic Queries | CRUD Operations in MongoDB | MongoDB Compass

preview_player
Показать описание
Hi guys,

In this lesson, we talk about basic CRUD queries on mongoDB. Like RDBMS, CRUD operations can be handled on MongoDB easily.
To show them we will go on with examples.
Our first operation will be to create a Database. By the way, we can reach to mongoDB databases from mongo shell or MongoDB Compass.

To create a database our query is “use db_name”. For example, if we want to create a database like db_test, our query will be “use db_test“.

These operations also can be handled via MongoDB Compass User Interface.

In here data format will be json. For example; name, role etc.

On MongoDB, we can also aggregate data. Like group by, sum etc. Actually, in MongoDB, to do it, we have aggregate function of collection.

{"$group" : {_id:"$role", count:{$sum:1}}}
])

Ok, now let’s check MongoDB Compass User Interface. Actually, this all commands can be handled on MongoDB Compass User Interface.

On MongoDB Compass User Interface, we can filter collection records with conditions, projections and sortings. These all formats should be in json format.

On MongoDB Compass User Interface, we can aggregate collection data. Actually in here, you will notice, there are some stages. This means mongoDB provides aggregation as pipeline. So first of all, you can group data then you can sort it.

On MongoDB Compass User Interface, we can analyze the schema structure of collection data.

On MongoDB Compass User Interface, we can analyze queries. You know that we can generally use it to understand the performance of queries as cost and time.

On MongoDB Compass User Interface, we can create indexes for performance. We will see an example about it in the next lesson.
On MongoDB Compass User Interface, we can describe rules like RDBMS. For example, we can describe not null fields, or we can describe field types.

collMod: "users",
validator: {
required: ["user-id"],
properties: {
"user-id": {
bsonType: "int",
description: "must be an integer"
},
}
}})

That’s all.
Thank you.
Рекомендации по теме