Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added global id option to disable id on schemas #12067

Merged
merged 4 commits into from Jul 20, 2022
Merged

added global id option to disable id on schemas #12067

merged 4 commits into from Jul 20, 2022

Conversation

IslandRhythms
Copy link
Collaborator

No description provided.

@IslandRhythms IslandRhythms changed the title added global id option added global id option to disable id on schemas Jul 7, 2022
@IslandRhythms IslandRhythms linked an issue Jul 7, 2022 that may be closed by this pull request
2 tasks
Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks!

Can you add TS types+test to the PR as well?

Also, is there an option to set this on schema definition or only as a global option for now? It'd be nice if we can have an option to do that on the schema, but we can do it on a future PR.

@IslandRhythms IslandRhythms self-assigned this Jul 11, 2022
@hasezoey
Copy link
Collaborator

@AbdelrahmanHafez

Also, is there an option to set this on schema definition or only as a global option for now? It'd be nice if we can have an option to do that on the schema, but we can do it on a future PR.

could you explain what you mean with that? from what i can tell, this PR is about adding a global option for disabling the id virtual, which was and still is a option in the schemaOptions (second parameter to new Schema(.., Here))

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add id to the TypeScript definitions for global Mongoose options here: https://github.com/Automattic/mongoose/blob/d742f4e71a026bc26acae0b4a797108af134f319/types/mongooseoptions.d.ts

@vkarpov15
Copy link
Collaborator

@AbdelrahmanHafez you can already set this on the schema level. new Schema({ name: String }, { id: false }).

@AbdelrahmanHafez
Copy link
Collaborator

Thanks, I didn't know that.
@vkarpov15

@vkarpov15 vkarpov15 changed the base branch from master to 6.5 July 18, 2022 19:17
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 vkarpov15 merged commit 6fcc0dc into 6.5 Jul 20, 2022
@vkarpov15 vkarpov15 deleted the gh-11966 branch July 20, 2022 15:06
hasezoey added a commit to hasezoey/mongoose that referenced this pull request Jul 20, 2022
AbdelrahmanHafez added a commit that referenced this pull request Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global option to disable id virtual for all schemas by default
4 participants