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

Add an option to generate required named param in the model's constructor #1114

Closed
lhengl opened this issue Jan 21, 2023 · 3 comments
Closed

Comments

@lhengl
Copy link

lhengl commented Jan 21, 2023

Problem

Currently, the way the models constructors are being generated are as follow:

  • late ObjectId id; // generates a positional parameter
  • late String? maybeDescription; // generates an named nullable parameter
  • late double milesTravelled = 0; // generates a named non-nullable parameter with a default value

What if you wanted a non-nullable named parameter without a default value? (For example, if the default value is generated from a function call, and not a constant.) You're out of luck, you're stuck with positional params - which is fine when there are only a couple. When there are more than a couple of them, it becomes harder to manage. It would be nice to have an option to generate a required field.

Solution

Solution: Add a @required PropertyAnnotation that will generate a required named param instead of a positional param

Alternatives

Alternative solution: Turn all positional parameter into required name parameter.

How important is this improvement for you?

I would like to have it but have a workaround

Feature would mainly be used with

Atlas App Services: Auth or Functions etc

@desistefanova
Copy link
Contributor

Hi @lhengl!
Thanks for giving your feedback!
It seems to be important for people using the Realm, since we have received the same request before. Probably you will be interest to read the conversation here #292.
We already have this issue in the list, but we are currently working on other priority tasks.
Probably, we can close this issue as duplicated.

@sync-by-unito sync-by-unito bot closed this as completed Jan 23, 2023
@sync-by-unito
Copy link

sync-by-unito bot commented Jan 23, 2023

➤ desistefanova commented:

Duplicated: https://jira.mongodb.org/browse/RDART-188

@lhengl
Copy link
Author

lhengl commented Jan 27, 2023

Thanks @desistefanova for pointing this out, I've subscribed to #292.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants