1// Update the document using `updateOne()`
2await CharacterModel.updateOne({ name: 'Jon Snow' }, {
3 title: 'King in the North'
4});
5
6// Load the document to see the updated value
7const doc = await CharacterModel.findOne();
8doc.title; // "King in the North"
1const query = {} //your query here
2const update = {} //your update in json here
3const option = {new: true} //will return updated document
4
5const user = await User.findOneAndUpdate(query , update, option)
6
1const res = await Person.updateOne({ name: 'Jean-Luc Picard' }, { ship: 'USS Enterprise' });
2res.n; // Number of documents matched
3res.nModified; // Number of documents modified