-
Notifications
You must be signed in to change notification settings - Fork 173
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
Expose a Obj::get_parent API #3898
Comments
Not sure if this is the same problem, but I think one of the comments I made here realm/realm-swift#7145 (comment) is very relevant for this. Without the ability to check backlinks during migrations it is pretty much impossible to migrate a list of realm objects to a list of embedded objects. The enumeration approach suggested here realm/realm-swift#7145 (comment) does not really work in real world scenarios. I tested this approach to migrate a typically users data (2MB of data) and the migration took 5 minutes to run when all I need to do is to remove orphaned objects that you seem to be able to easily detect once the migration block has completed. |
@ianpward @fealebenpae can we bump the priority of this? It's been almost a year since we decided to "do it shortly after the launch of embedded objects". |
@ianpward @nirinchev Can we bump this? We just had another request for this functionality, and unfortunately backlinks don't solve all the needs |
@bmunkholm is this on the quick wins list? |
@ianpward Yavor is assigned now. |
➤ Nikola Irinchev commented: [~[email protected]] is this really in progress? Should we move it to the backlog in order to prioritize it at the next Core planning? Seems like a good intro task for a new hire/new grad. |
@nicola-cab was this closed by accident? I'm not sure the linked PR addresses the parent API. |
No, it is wanted. Why do you need to get all the backlinks? Why don't you try to let core handle that, instructing core with the new configuration? Especially because the algorithm for migrating tables from top to embedded is quite complicated, surely not something to write in the SDK. |
This request is not related to migrations - it's a convenience API for obtaining the parent of an embedded object. It was part of the scope/design of EmbeddedObjects but was not implemented due to lack of time. |
OK, then reopen it, but why do you need such API? For checking if the embedded object has a parent? for checking if the migration would succeed? All this is now handled in core.. |
No, it's needed to be able to delete an embedded object (among other reasons that I have forgotten since it was 2 years ago). Since we decided to disallow direct deletion of embedded objects (e.g. Additionally, it is useful since embedded objects can be contained in multiple parent types and enumerating all of them with the SDK backlinks syntax would be annoying. This is because backlinks exposed in the SDKs are typed, so you'll need to do something like:
|
@nirinchev we have |
@ironage I just made support for this |
Seems like internally, we can get an embedded object's parent via
get_all_backlinks
, but there's no API to do it, other than very inefficiently getting the path, then trying to traverse it until the first top-level object.The text was updated successfully, but these errors were encountered: