сохранение или обновление мангуза
// This will create another document if it doesn't exist
findByIdAndUpdate(_id, { something: 'updated' }, { upsert: true });
florinrelea
// This will create another document if it doesn't exist
findByIdAndUpdate(_id, { something: 'updated' }, { upsert: true });
const res = await Person.updateOne({ name: 'Jean-Luc Picard' }, { ship: 'USS Enterprise' });
res.n; // Number of documents matched
res.nModified; // Number of documents modified
var conditions = { name: 'bourne' }
, update = { $inc: { visits: 1 }}
Model.update(conditions, update, { multi: true }).then(updatedRows=>{
}).catch(err=>{
console.log(err)
})
model.updateOne({_id:'YOURID'}, {DATA YOU WANT TO UPDATE}, (err, result) => {
if(err) throw err
console.log(err)
})