Can I create a DocumentArray without the sub-document _id?
See original GitHub issueWhen 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?
Issue Analytics
- State:
- Created 10 years ago
- Comments:5
Top Results From Across the Web
Stop Mongoose from creating _id property for sub-document ...
You can create sub-documents without schema and avoid _id . Just add _id: false to your subdocument declaration. var schema = new mongoose....
Read more >Mongoose v6.8.1: SubDocuments
Each subdocument has an _id by default. Mongoose document arrays have a special id method for searching a document array to find a...
Read more >Stop Mongoose from creating _id property for sub ... - Intellipaat
If you want to stop Mongoose from creating _id property for sub-document array items it's very simple, you can define this in the...
Read more >How to disable MongoDB from creating ids for subdocuments
Mongoose allows you to restrict subdocuments so that they do not have an id . Structuring your schema. First, let's create a schema...
Read more >Stop Mongoose from creating _id property for sub-document ...
[Solved]-Stop Mongoose from creating _id property for sub-document array items-mongodb ... You can create sub-documents without schema and avoid _id .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
new Schema({..}, { _id: false })
Roger that.
I started out without defining a Schema for the names and that’s why I hit the wall.