boba poorna
boba poorna

Reputation: 251

update multiple records in mongodb using mongoose

I have mongodb collection with below documents.

enter image description here

I wanted to update phone = 9876054321 where Email = [email protected] in Nodejs mongoose. My results should be like below. enter image description here

Upvotes: 0

Views: 233

Answers (1)

Mohammad Yaser Ahmadi
Mohammad Yaser Ahmadi

Reputation: 5051

if the Model created correctly, just try

await Model.updateMany({ Email : "[email protected]" }, { phone : 9876054321 });
let result = await Model.find({Email  : "[email protected]"}).lean();
console.log(result)

Upvotes: 1

Related Questions