Preserve References on Reload #116
Unanswered
doc-duncan
asked this question in
Q&A
Replies: 1 comment
-
Hi doc, this is a cool problem. You could probably accomplish something like this using a custom query that loads all relationships except A, however the current load logic assumes you are loading into a fresh struct so you can definitely run into some undefined behavior. With some alterations to the load logic to take the load map into account (a bit of state loaded with each node describing what relationships it was loaded with: https://github.com/mindstand/gogm/blob/ff5ee1f99251817c550d663e3d30d5d33f4f83ef/model.go#L32) GOGM could probably be adapted to fit this use case. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey all, wondering if something is possible...
As we know, loading at a large depth is expensive. Therefore, in my project I am loading at a depth of 1 "as needed".
For example, let's say I have two nodes and one relationship between them.
A-[:depends_on]->B
Let's then say I load all the A nodes at a depth of 1 into a slice of pointers: s := []*A{}
Now obviously s will have all my A's with the depends_on relationship to End node B. And furthermore, B will have a reference back to the same object, A. Meaning if I change A.dependsOn.End.HasDependent.Start.Name = "new-name". Then the A reference will be updated, which is the key for me.
However, let's now go back to the original problem. When I get to B from A I want to reload B with a depth of 1 to get its other relationships as well. However, I want to maintain the original reference to A. Currently when I reload B I get a new reference and lose that ability to modify A from B.
Is this possible? Thanks a bunch!!
Beta Was this translation helpful? Give feedback.
All reactions