These are chat archives for Automattic/mongoose

5th
Jul 2015
dragonman123
@dragonman123
Jul 05 2015 23:40
Hey can anyone help me, I am having some trouble
..??
I am having this entry in my collection in a database in mongodb
{
"_id" : ObjectId("559948580f12275906650f68"),
"arr" : [
{
"name" : "Eric",
"age" : 12
},
{
"name" : "Elvis",
"age" : 14
}
],
"type" : "friends"
}
I want to add one more entry which is like.
{name: "Bob", "age": 20}, into the array arr.
How can I do that in mongoose.?
I have tried
ObjectModel.update(
{"type": "friends"},
{ $push : {arr: {"name": "Bob", "age":20}}},
function(err){
console.log("Added")
}
);
dragonman123
@dragonman123
Jul 05 2015 23:45
Which pushes an empty object in the collection, how can I solve this.?
This message was deleted