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);
});
--
You received this message because you are subscribed to the Google Groups
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/d/optout.