For example
var PersonSchame = new mongoose.Schema({
name: String,
books: [{
type:String
}]
});
How to add data to books at this time
Basic question :)
ringa_lee2017-05-02 09:26:46
Do you mean to add elements to the books field of a piece of data in the database? If so, refer to the following example:
db.personModel.update({
_id: xxx //查询到特定的一条数据
}, {
$push:{
members: username
}
}, (err) => {
//update操作完之后的回调函数
});
高洛峰2017-05-02 09:26:46
See the old post, which contains the $push part of Mongoose:
/q/10...
For reference.
Love MongoDB! Have Fun!