Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoose find and update prop

var query = {'username': req.user.username};
req.newData.username = req.user.username;

MyModel.findOneAndUpdate(query, req.newData, {upsert: true}, function(err, doc) {
    if (err) return res.send(500, {error: err});
    return res.send('Succesfully saved.');
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mongoose #find #update #prop
ADD COMMENT
Topic
Name
2+9 =