My schema is as follows:
var schema = new mongoose.Schema({
_id: String,
name:String,
to:[{
name: String,
message: [{
content: String
timestamp: Date
}]
}]
});
I need to push the {content: Content, timeStamp: timestamp}
to the message
array where to.name == "someName"
.
I tried in this way but could not succeed.Please help me.
User
.find({_id: id})
.where('to.name').equals("someName")
.to.message.push({content: Content, timeStamp: timestamp})
.exec(function(err, doc){
if(err) return console.log(err);
console.log(doc);
});