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
Currently the model class must be direct descendant of Realm.Object class,
But creating many model class with repetitive field or methods could be exhausting (for example when all model should have _id, and createdAt field), so i tried to create a super class BaseModel which extends Realm.Object to handle that common fields and methods, then i would write my actual model extending that BaseModel
In this case i created UserPreference Model extending BaseModel
but then realm throw error like this [Error: Exception in HostFunction: Class 'UserPreference' (declaring 'user_preference' schema) must extend Realm.Object]
for now i have to rewrite the BaseModel as an Interface, and the model implements it, so i don't miss the basic field that all of my models should have, but at the cost of repetitive code
How important is this improvement for you?
Fairly niche, but nice to have anyway.
The text was updated successfully, but these errors were encountered:
@deckyfx Thank you for the suggestion. I agree that superclassing is the next natural step. It does also come up in other Realm SDKs, and it is a feature we would like to implement. I can't give us an estimate for when.
Problem
Currently the model class must be direct descendant of Realm.Object class,
But creating many model class with repetitive field or methods could be exhausting (for example when all model should have _id, and createdAt field), so i tried to create a super class BaseModel which extends Realm.Object to handle that common fields and methods, then i would write my actual model extending that BaseModel
In this case i created UserPreference Model extending BaseModel
but then realm throw error like this
[Error: Exception in HostFunction: Class 'UserPreference' (declaring 'user_preference' schema) must extend Realm.Object]
Edit, i forgot to put my specs
Solution
for now i have to rewrite the BaseModel as an Interface, and the model implements it, so i don't miss the basic field that all of my models should have, but at the cost of repetitive code
How important is this improvement for you?
Fairly niche, but nice to have anyway.
The text was updated successfully, but these errors were encountered: