1// This will create another document if it doesn't exist
2findByIdAndUpdate(_id, { something: 'updated' }, { upsert: true });
1const res = await Person.updateOne({ name: 'Jean-Luc Picard' }, { ship: 'USS Enterprise' });
2res.n; // Number of documents matched
3res.nModified; // Number of documents modified
1var conditions = { name: 'bourne' }
2 , update = { $inc: { visits: 1 }}
3
4Model.update(conditions, update, { multi: true }).then(updatedRows=>{
5
6}).catch(err=>{
7 console.log(err)
8
9})