CRUD OPERATIONS IN MONGODB
mongodb
database
data
coding
INTRODUCTION
MongoDB is one of the most popular NoSQL databases, widely used for its flexibility and scalability. Unlike relational databases, MongoDB stores data in collections as JSON-like documents.
In this blog, we’ll perform CRUD (Create, Read, Update, Delete) operations on a simple college student schema to understand MongoDB basics hands-on.
Here we are using MongoDB Shell for scripting in MongoDB Compass
run all the commands in MongoDB Shell. this will work great.
Student Schema
We’ll use a collection called students, and each document follows this basic structure:
{
Create (Insert)
Inserting 5 student records:
This will create 5 documents in the students collection.
Read (Query)
Display all student records:
db.students.find()
Find all students with CGPA > 8:
db.students.find({ cgpa: { $gt: 8 } })
Top comments (0)