Mongoose 3 supports declaring an embedded document schema directly in the parent object, without declaration a separate schema object. This is described as the "Alternate declaration syntax" in the documentation here:
http://mongoosejs.com/docs/subdocs.html
with an example given:
var parentSchema = new Schema({
children: [{ name: 'string' }]
})
I'd like to use this form, but disable the autogenerated ID property of the embedded object. Is there a way to do this? The documentation only describes how to disable it when you're defining a separate schema instance.
When defining a schema you can specify options as a second parameter. Set _id to false to disable auto _id.
var parentSchema = new Schema({
children: String
}, {
_id: false
})
Refer Docs : http://mongoosejs.com/docs/guide.html#_id
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