Mongoose: Can I create a DocumentArray without the sub-document _id?

Created on 20 May 2013  路  5Comments  路  Source: Automattic/mongoose

When I have such a Schema:

var StudentSchema = new Schema({
  _id : Schema.Types.ObjectId,
  clazz : { type: String, ref: 'Class' },
  number : { type: Number },
  name : [{
    lang: String,
    full : { type: String, trim: true }
  }]
});

Each name would be automatically added an _id.
I would not use if for any operation my use case, how can I specify in the Schema to drop it?

Most helpful comment

new Schema({..}, { _id: false })

All 5 comments

To my understanding I've to create a Schema to set { _id: false }, is that your suggested way?

yes

new Schema({..}, { _id: false })

Roger that.

I started out without defining a Schema for the names and that's why I hit the wall.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CodeurSauvage picture CodeurSauvage  路  3Comments

gustavomanolo picture gustavomanolo  路  3Comments

varunjayaraman picture varunjayaraman  路  3Comments

efkan picture efkan  路  3Comments

simonxca picture simonxca  路  3Comments