For examplevar PersonSchame = new mongoose.Schema({
name: String, books: [{ type:String }]
});
How to add data to books at this time
Basic question :)
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操作完之后的回调函数 });
See the old post, which contains the $push part of Mongoose:
/q/10...
For reference.
Love MongoDB! Have Fun!
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:
See the old post, which contains the $push part of Mongoose:
/q/10...
For reference.
Love MongoDB! Have Fun!