0% found this document useful (0 votes)
92 views4 pages

Experiment No.8 MongoDB CRUD

This document discusses CRUD operations in MongoDB. It covers how to create collections using createCollection() and insert documents using insertOne() and insertMany(). It also covers read operations using find(), findOne(), update operations using updateOne(), updateMany(), replaceOne(), and delete operations using deleteOne() and deleteMany().

Uploaded by

pavan nirmal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views4 pages

Experiment No.8 MongoDB CRUD

This document discusses CRUD operations in MongoDB. It covers how to create collections using createCollection() and insert documents using insertOne() and insertMany(). It also covers read operations using find(), findOne(), update operations using updateOne(), updateMany(), replaceOne(), and delete operations using deleteOne() and deleteMany().

Uploaded by

pavan nirmal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CURD in MongoDB:

CREATE OPERATIONS
createCollection():
use bvc

db.createCollection(‘Library’)

InsertOne():

db.Library.insertOne({‘name’:’Rishi’,’bookname’:’java’,’member_since’:2})

insertMany():

db.Library.insertMany([

{'name':'jack','bookname':'c++','member_since':5},

{'name':'king','bookname':'c','member_since':1,'role':'manager'},

{'name':'Rishi','bookname':'python','member_since':3}

])
READ OPERATIONS:
find():
db.Library.find()

db.Library.find({name:'jack'})

findOne():
db.Library.findOne({name:'Rishi'})
UPDATE OPERATIONS:
updateOne():

db.Library.updateOne({name:'jack'},{$set:{name:'Jack',bookname:'Mysql',member_since:'5'}})

updateMany():

db.Library.updateMany({name:'Rishi'},{$set:{member_since:1}})

replaceOne():

db.Library.replaceOne({name:'king'},{name:'queen'})
DELETE OPERATIONS:
deleteOne():
db.Library.deleteOne({name:'queen'})

deleteMany():
db.Library.deleteMany({name:'Rishi'})

You might also like