Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to append data to a field in mongoose model

exports.addFriend = function (req, res, next)
{
var friend = {"firstName": req.body.fName, "lastName": req.body.lName};
Users.findOneAndUpdate({name: req.user.name}, {$push: {friends: friend}});
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #append #data #field #mongoose #model
ADD COMMENT
Topic
Name
4+8 =