Discussion:
Re-root an entity component elsewhere
Dustin Getz
2017-07-15 17:37:13 UTC
Permalink
I am flattening out a level in my model. I have lots of component entities
(isComponent true), and there are also many regular references to those
entities that are not component. I want to move the component entities by
rooting them somewhere else; the attribute is the same, but now the
components have a different owning entity than before. Doing it this way
will preserve the non-component references to the children. Then I want to
retract the old parent. Is this possible to do? Is it possible to do
atomically?
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dustin Getz
2017-07-15 18:03:16 UTC
Permalink
It appears to work as two transactions - where the :db.fn/retractEntity for
the old owner, happen in a second transaction after the re-parenting. If I
try to do it atomically, the components are deleted and not moved.

Also there might be a bug here. I am staging all my transactions through
d/with to visually test them before transacting. I swear I saw the atomic
transaction successfully hydrate through Datomic, when the
:db.fn/retractEntity statements were last, and then moving them to the
front of the transaction caused the components to be deleted and not moved.
I know I saw it because I was shocked that it worked, and on instinct
decided to move them to the front and see, because its my understanding
that all :db.fn statements are automatically sorted to the front. I was
unable to reproduce it again.
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...