Basic CRUD operations in MongoDB-Programmingraja
Basic CRUD operations in MongoDB
> use mydb;
switched to db mydb
-----------------------------------------------------------------------------
> db.stud.insert({
rollno:"121",
name:"Ekta",
course:"MCA"})
WriteResult({ "nInserted" : 1 })
----------------------------------------------------------------------------
> db.stud.find().pretty()
{
"_id" : ObjectId("618a787d33923f3b67ca5a3e"),
"rollno" : "121",
"name" : "Ekta",
"course" : "MCA"
}
-------------------------------------------------------------------------------
> db.stud.update(
... {
... "rollno":"121"
... },
... {
... $set:
... {"name":"Ekta Dhoke"}
... })
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
---------------------------------------------------------------------------------
> db.stud.remove({"rollno":"121"})
WriteResult({ "nRemoved" : 1 })
-------------------------------------------------------------------------------
> db.stud.find()
>
0 Comments
if you have any problem, please let me know