Mca - V20pca104 - Ec2332251010489

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

PRACTICAL EXAM ANSWER-SHEET

Enrollment Number: EC2332251010489 Name of student: Tushar Chaudhary

Date:14-07-2023 Subject Code: V20PCA104


Name of Subject: Advanced Web Applica on
Development

Title:Write Mongo CRUD Opera ons

Aim: Write Mongo CRUD Opera ons


The following opera ons are used to create (C), read (R), update (U), and delete
(D) a document in MONGO DB and are called as CRUD Opera ons.

Procedure/Steps:
1. Create operation - Create operation or Insert operation are used to add new documents to the
collection and if the collection does not exist, it creates one. :- db.collection.insert()
2. Read opera on – This opera on reads the documents from the collec on. Thisprocess is taken
place by execu ng a query. :-–db.collec on. nd()

3. Update opera on –Update opera on is used to modify an exis ng document.:-


db.collec on.update()

4. Delete opera on – Delete opera on erases the document from the collec on.:-
db.collec on.remove()

Program:

Create:
Create opera ons add new documents to a collec on. There are two ways to add new documents
to collec ons:
db.collec on.insertOne()
db.collection.insertMany()

ti

ti
ti
ti
ti
ti
ti
ti

ti

ti

ti

ti
ti
ti
ti
ti

ti
fi

ti
ti
ti

ti
ti

Read:
Read opera ons retrieve documents from a collec on. If thereis no collec on that currently exists,
it will automa cally createa new one.
Here is the method to retrieve informa on:
db.collec on. nd()

Update:

Update opera ons modify documents from a collec on.The three ways to add new documents to
collec ons are:
db.collec on.updateOne()
db.collection.updateMany()
db.collec on.replaceOne()
ti

ti
ti
ti
ti
fi
ti
ti

ti

ti
ti
ti
Delete:
Delete opera ons delete documents from a collec on. There are two ways to add new documents
to collec ons:
db.collec on.deleteOne()
db.collection.deleteMany()

RESULT/OUTPUT:
All Mongo CRUD Opera ons are successfully executed.

ti
ti
ti

ti

ti

You might also like