-
Notifications
You must be signed in to change notification settings - Fork 585
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
Realm.delete is not working with class schema #2848
Comments
@amereii
then In the future we are planning on phasing out the support of classes not explicitly extending |
@blagoev after extending from
|
I also get the same error
It happens when calling The code causing this in bundle.js looks like this:
This started to happen after I updated react-native 0.59 → 0.62.2 and Realm 2.29.2 → 5.0.4. EDIT: It seems that this happens even if I revert Realm back to 2.29.2, but still keep react-native 0.62.2 and some other libraries updated. When running old react-native 0.59 and Realm 2.29.2, there is no EDIT 2: If I'm correct, the code pasted above (Reflect.construct) is not related to Realm, but is generated from Babel. However, it also did not help even if I downgraded Babel. |
Has anyone come up with any solution? |
I'm desperately needing a solution for this too. My app seems stuck in a broken state.
I'd be happy for temporary hacks or workarounds at this point. |
@bkbooth I've found a workaround for now. @blagoev mentioned this issue is specific to class-based schemas, so the workaround is to pass the schemas directly. The change was actually pretty small for me. When I call
to
So, I just appended |
@Gazzini do you have instance methods on your classes? Do they still work when you only pass the schema objects to If not I think what you've done is roughly the same as what I've ended up doing. I changed all of my class models to plain objects (with the schema object as a property that I'm passing to I had to refactor any class instance methods to functions that took the instance as the first param instead of accessing as If instance methods still work with your way, well, I wish I knew that yesterday, haha. Would have saved me a bunch of time refactoring things. |
Ah, no instance methods for me. I keep my models dumb. |
Got the same error on RN 0.62.2 and realm 3.6.5 (didn't get this error on RN 0.61.5) |
@blagoev One month passed, Do you have plan to fix the bug? It must be a priority
|
this problem may be related to RN 0.62 |
we are with tight resources but I will try to investigate that. |
@Jarzka my understanding is that passing the whole class is a relatively new feature (maybe only since v5?), it seems like they're moving towards it being the preferred way to provide schema's, but in my experience it isn't production ready yet. I refactored all of our usage of Realm away from classes to using plain objects and only passing the schema objects to |
Interesting because in our app, we have passed the whole class. It worked before I tried to upgrade Realm from version 2 to 5 and RN to 0.62. However, I'm not the original developer of our app so don't really know if this is the preferred way or a mistake that has just worked. |
Right, I could be completely wrong in my understanding then 🤷♂️ I've been building a new app, we only added Realm at |
I have this problem too |
I was able to solve the writing issue with the workaround explained by @Gazzini. But now, when I read things from Realm, it always returns empty objects...
Returns:
I checked that MySchema contains data in the database by pulling the database out of the device and exploring it with Realm Studio. The problem also applies to all schemas. I'm running Realm 5.0.5. EDIT: There seems to be thread of this issue: #2763 EDIT 2: It seems that this empty object issue can be "solved" by downgrading back to 3.6.5. |
@kneth @blagoev @fealebenpae take a look please!! |
Found a workaround without having to drop back to dumb objects: const collection = db.objects('schema-name').filtered(`id = $0`, id)
db.delete(collection); This is a pretty bad bug and it was first reported 3 months ago. There's been all sorts of new versions since then with new features - does it not make sense perhaps to fix existing features before adding new features on top of them? I don't know cpp but the issue seems to be here - Line 1021 in 0a151f9
|
We have fixed the realm.delete error. It will be included in our next release. Thanks for reporting it. |
Hello what is id here is it primary key ? error [ReferenceError: Can't find variable: ID ] also I am facing an issue says error [Error: Can only delete objects within a transaction.] in RN 0.63 |
Goals
Realm.delete works on older versions , After upgrading from 3.4.1 to 5.0.3 , Realm.delete is not working with class schema
Actual Results
Steps to Reproduce
Code Sample
Version of Realm and Tooling
The text was updated successfully, but these errors were encountered: