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

SchemaType-level global setters to go along with global getters #13510

Closed
2 tasks done
vkarpov15 opened this issue Jun 14, 2023 · 0 comments · Fixed by #13538
Closed
2 tasks done

SchemaType-level global setters to go along with global getters #13510

vkarpov15 opened this issue Jun 14, 2023 · 0 comments · Fixed by #13538
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class
Milestone

Comments

@vkarpov15
Copy link
Collaborator

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

In #11462, I ran into an issue where you can set a global getter on all date instances:

mongoose.Schema.Types.Date.get(v => {
  return Temporal.Instant.fromEpochSeconds(v.valueOf() / 1000);
});

But there's no way to set a corresponding global setter.

Motivation

Getters and setters are complementary, and while it is definitely possible to get a lot out of global getters without global setters, having both is necessary.

The major roadblock is that we use SchemaType.get() to define global getters... but SchemaType.set() is already used to set global schematype options. So we may instead need to do something like mongoose.Schema.Types.Date.setters.push(...) instead of mongoose.Schema.Types.Date.set().

Example

No response

@vkarpov15 vkarpov15 added new feature This change adds new functionality, like a new method or class enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature labels Jun 14, 2023
@vkarpov15 vkarpov15 added this to the 7.4.0 milestone Jun 14, 2023
@IslandRhythms IslandRhythms linked a pull request Jun 27, 2023 that will close this issue
vkarpov15 added a commit that referenced this issue Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant