I am trying to update collection using mongoose with NodeJS .when I log data to NodeJs console it prints the data but not data is not being pushed in collection. But when i run the same query on mongodb console then it works Here's the code
portoflio is array of objects
portfolio_user={ 'title' : 'this is the sample link', 'type" : 'link', 'url" : 'www.emumba.com' }
var user_id=req.user._id;
console.log(user_id);
var portfolio_user=req.body;
console.log(portfolio_user)
User.update({_id:user_id},{
$push:{
"portfolio":portfolio_user
}
},
function(err, user){
if (err) {
console.log(err);
} else {
console.log(user);
res.jsonp(user);
}
});
Note: I have also tried findOneAndUpdate and findById but they still dont work
via shaheer khan
No comments:
Post a Comment