Skip to content

Commit f7394ad

Browse files
committed
docs: how to remove _id in embedded documents
closes #239
1 parent 82e64d1 commit f7394ad

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,21 @@ const UserTCForSchema1 = composeWithMongoose(User, { schemaComposer: schema1 });
513513
const UserTCForSchema2 = composeWithMongoose(User, { schemaComposer: schema2 });
514514
```
515515

516+
### Embedded documents has `_id` field and you don't need it?
517+
518+
Just turn them off in mongoose:
519+
520+
```js
521+
const UsersSchema = new Schema({
522+
_id: { type: String }
523+
emails: [{
524+
_id: false, // <-- disable id addition in mongoose
525+
address: { type: String },
526+
verified: Boolean
527+
}]
528+
});
529+
```
530+
516531
## Customization options
517532

518533
When we convert model `const UserTC = composeWithMongoose(User, customizationOptions);` you may tune every piece of future derived types and resolvers.

0 commit comments

Comments
 (0)