Datomic documentation recommends modeling relationships in one direction only. So, if I have a reference "whole" on an entity "part", I don't need to declare another reference "parts" on an entity "whole". The following attribute declaration is enough.
{:db/ident :part/whole
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one}
Then, I can use :part/_whole
as a key to fetch all parts of a "whole". Even though it works, it's counterintuitive at times.
Is there a way to create a permanent alias for the reverse relationship, equivalent to the pull pattern :as
option?
(d/pull db '[* {[:part/_whole :as :whole/parts] [*]}] whole-db-id)