-
Notifications
You must be signed in to change notification settings - Fork 92
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
Private properties are ignored on Realm model generation #1367
Comments
We hear you. For now perhaps rename |
You don't need the |
Thanks @nielsenko. Yes the |
We will definitely consider. Just have to think it through, but I don't see any immediate reason as why not to allow them. Perhaps hidden behind a configuration flag. |
Any updates on this please ? We have a huge number of enums (stored as strings in MongoDB Atlas) and the proposed approach above would be much appreciated to streamline the development and strictly typed nature - i.e. we can map 'strings' in Realm data base models to Dart enums. |
It would be awesome to take this a step further and add support for enums directly and avoid the boiler-plate. Annotations such as
or
Could be used the specify how to store the enum. |
@dotjon0 This is now supported with 2.1.0. @derrickgw I appreciate your suggestion, but one problem for us is that enums behave very differently across the various SDK languages. There are multiple issues requesting the same:
It would be fairly trivial to add for the Dart SDK, but we exists in a larger eco-system. I will bring it up internally. |
Amazing @nielsenko thank you soooo much! really appreciated! Will transform enums in Flutter Realm. |
@nielsenko Thanks. I recognize that adding enum support at the file level would require a lot of effort and coordination. But in the meantime storing them as string or ints is essentially what we do now. Adding a dart-only annotation to automate that would be great, and might even make it easier to migrate later if/when the file format supports enums. |
@derrickgw if you build your Realm models automatically, you can then automatically create the required setters and getters for enums, so likely the result you're after i.e.
|
@dotjon0 |
@derrickgw yes in an ideal world for sure. Note there is an open feature request for this #681 |
What happened?
So we have the below code. When we run
dart run realm generate
the_type
property is not generated in the Realm.g.dart
part file.... There is no warning message. Ideally it would be amazing if the Realm team could support private properties - use case below (can think of many more, please ask):The outcome we are looking to achieve is to make 'enums' (stored in the database as a
String
) and instance of theenum
via getters. So when you accessCar.type
it outputs a value fromCarType
enum.Repro steps
See above
Version
^1.0.3
What Atlas Services are you using?
Atlas Device Sync
What type of application is this?
Flutter Application
Client OS and version
macOS 13.4.1
Code snippets
See above
Stacktrace of the exception/crash you're getting
Relevant log output
The text was updated successfully, but these errors were encountered: