0
我的模式如下:推一個元素陣列的貓鼬文檔中
var schema = new mongoose.Schema({
_id: String,
name:String,
to:[{
name: String,
message: [{
content: String
timestamp: Date
}]
}]
});
我需要將{content: Content, timeStamp: timestamp}
推到message
陣列,其中to.name == "someName"
。
我以這種方式嘗試過,但不能成功。請幫助我。
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);
});