var Embedded = new Schema({
some: String
})
var Main = new Schema({
other: String,
em: [Embedded]
})
On Main.save({other:1, em:[{some:2}]}) mongoose
adds object {other:1, em:[{some:2,"_id" : ObjectId("51f6d89a6269170000000039")}]} to the database.
Can I say to mongoose not to add _id to embedded document?
When defining a schema you can specify options as a second parameter. Set _id to false to disable auto _id.
var Embedded = new Schema({
some: String
}, {
_id: false
})
See the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With