showing results for - "update mongoose"
Sebastián
17 Feb 2019
1var query = {'username': req.user.username};
2req.newData.username = req.user.username;
3
4MyModel.findOneAndUpdate(query, req.newData, {upsert: true}, function(err, doc) {
5    if (err) return res.send(500, {error: err});
6    return res.send('Succesfully saved.');
7});
8
Micaela
30 May 2017
1app.put('/student/:id', (req, res) => {
2    Student.findByIdAndUpdate(req.params.id, req.body, (err, user) => {
3        if (err) {
4            return res
5                .status(500)
6                .send({error: "unsuccessful"})
7        };
8        res.send({success: "success"});
9    });
10
11});
Loucas
17 Oct 2016
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})
Rémi
25 Sep 2020
1const res = await Person.updateOne({ name: 'Jean-Luc Picard' }, { ship: 'USS Enterprise' });
2res.n; // Number of documents matched
3res.nModified; // Number of documents modified
Loann
17 Mar 2018
1const MyModel = mongoose.model('Test', new Schema({ name: String }));
2const doc = new MyModel();
3
4doc instanceof MyModel; // true
5doc instanceof mongoose.Model; // true
6doc instanceof mongoose.Document; // true
Jamison
15 Oct 2016
1CommentaireArticleModel.update({ pseudo : 'Atinux'}, { pseudo : 'Nikita' }, { multi : true }, function (err) {
2  if (err) { throw err; }
3  console.log('Pseudos modifiés !');
4});
queries leading to this page
expressjs update mongoosemongoose update example nodejsupdate object data in mongoose arrayhow to update model mongooseupdate record in mongooseupdate query in mongodbmongoose overwrite dataupdate a record in mongooseupdate mongodb mongooseupdate value mongoosehow to update documents mongoosedocument update mongoosefind and update query in mongoosemongoose update and get documentmongoose update query in node jsfind and update in mongooseusing express create update mongoosemongoose update querymongoose updateupdate mongoose node jsalter data in mongoose modeledit object in mongoose formupdate data in mongoosemongoose node js updatehow to update value in mongoosemongoose mongodb nodejs update recordcant update data in database using mongoosepatch mongoosemongoose changing data with nodejsmongoose updateupdate mongoose if value in documenthow to update in mongooseupdate mongoose documentmongoose update methodhow to update data in mongooseedit a mongoose entrymongoose update recordmongoose update one by idupdate records in mongoosemongoose update bymongoose update record and get updated dataupdateone mongoosemongoose updateoneupdate in node js mongoosemongoose find document and update valuemongoose update new modelhow to update in monodb using mongooseupdate in mongoose setupdate in mongooseupdate mongoosemongoose find and updatehow to update data in mongodb using mongoosehow do i update in mongooseupdate on mongoosemongoose updateone by idhow to use mongoose updatemongoose to update mongodbmongoose update onemongoose to update mongodnode mongoose updateoneupdate mongoose