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

Mongoose CRUD Operations in MongoDB

The document summarizes an experiment conducted by a student named Nidhi Yadav to perform CRUD operations on a MongoDB database using Mongoose. The student connected to a MongoDB database using Mongoose, defined a schema and model. They then demonstrated inserting, reading, updating and deleting data from the collections using the model. The key learning outcomes were about MongoDB and performing CRUD operations.

Uploaded by

deadm2996
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)
39 views4 pages

Mongoose CRUD Operations in MongoDB

The document summarizes an experiment conducted by a student named Nidhi Yadav to perform CRUD operations on a MongoDB database using Mongoose. The student connected to a MongoDB database using Mongoose, defined a schema and model. They then demonstrated inserting, reading, updating and deleting data from the collections using the model. The key learning outcomes were about MongoDB and performing CRUD operations.

Uploaded by

deadm2996
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

Experiment:2.

Student Name: Nidhi Yadav UID:22MCA20001


Branch: MCA Section/Group: 3(A)
Semester: 3rd semester Date of Performance:15/10/2023
Subject Code: 22CAH-706 (Back End Technologies)

1. Use Mongoose to connect database for performing CRUD operations.

const mongoose = require("mongoose"); const


con=mongoose
.connect("mongodb://[Link]:27017/dev")
.then(() => {
[Link]("connected succesfully");
})
.catch((e) => {
[Link]("not cnnected", e);
});
const stdSchema = new [Link]({
Name: String,
UID: String,
Branch: String,});

const Model = [Link]("stud", stdSchema);

INSERT DATA:
[Link]([{
Name: "Nidhi Yadav",
UID: "22mca20001",
Branch: "MCA",
},{
Name: "Kashish",
UID: "22mca20021",
Branch: "MCA",
},{
Name: "Deepanshi",
UID: "22mca20501",
Branch: "MCA",
}])
.then((data) => {

[Link]();

[Link](data)

})
.catch((e) => {
[Link]();
});

inSert();

READ DATA:
const finds = async () => { await con; let

data = await [Link]({Name:'Paul'});

[Link](data);

};
finds();
UPDATE DATA:
const updates = async () => { await con; let data = await

[Link]({Name:'Kashish'},{Branch:'BCA'});

[Link](data);

};

updates();
DELETE DATA:
const Delete = async () => { await con; let data =

await [Link]({Name:'Paul'});

[Link](data);

};

updates();

LEARNING OUTPUT:
1. Learnt about Mongodb;
2. Learnt about CRUD.

You might also like