You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Everytime I use realm.create to create an object, the field createdAt uses the time I opened the app to be the default value.
I have tried to use realm.open for different creation but they are still all having the same createdAt field in one app launch.
Re-launching or reloading the app does generate a different default value, but I think it should be generated everytime we create an entry.
I believe that this behavior should be available for nearly every database framework and SQL statements, and Realm for Swift also support this behavior, so I am not sure if it is due to any configuration issue on my end, or is it not supported yet?
If it is supported, I wonder how I can get the expected behavior.
And if you are worrying about the API changes, it is possible to make another field to contain a function to generate the default value (so it will not stick to the value generated at the time schema is loaded).
This should be fairly important because manually creating default values every time (even by wrapping it) is really annoying and it should not exist in 2022. In SQL or other frameworks, it is already supported for a long time, so it struggled me at first when I realized that it is probably not supported by the realm-js yet.
How important is this improvement for you?
Dealbreaker
The text was updated successfully, but these errors were encountered:
@lilingxi01 Dynamic defaults are currently not supported. I agree it is a useful feature.
We are investigating how to support class-based models (related to #3587), which will be a stepping stone to become on par with Realm Swift's many new data modeling features.
Problem
This is kinda a follow up issue related to #2393 but not really.
I am facing a problem when I have a schema like this:
Everytime I use
realm.create
to create an object, the fieldcreatedAt
uses the time I opened the app to be the default value.I have tried to use
realm.open
for different creation but they are still all having the samecreatedAt
field in one app launch.Re-launching or reloading the app does generate a different default value, but I think it should be generated everytime we create an entry.
I believe that this behavior should be available for nearly every database framework and SQL statements, and Realm for Swift also support this behavior, so I am not sure if it is due to any configuration issue on my end, or is it not supported yet?
If it is supported, I wonder how I can get the expected behavior.
Solution
The solution in #2393 could be useful.
And if you are worrying about the API changes, it is possible to make another field to contain a function to generate the default value (so it will not stick to the value generated at the time schema is loaded).
This should be fairly important because manually creating default values every time (even by wrapping it) is really annoying and it should not exist in 2022. In SQL or other frameworks, it is already supported for a long time, so it struggled me at first when I realized that it is probably not supported by the realm-js yet.
How important is this improvement for you?
Dealbreaker
The text was updated successfully, but these errors were encountered: