Fork me on GitHub
#datascript
<
2017-11-29
>
eoliphant20:11:57

Hi, I’m getting this error

"Lookup ref should co … 8377-693ad05f97ea"]]"
Lookup ref should contain 2 elements: [[:field/id #uuid "9c53d227-d84e-4e49-8377-693ad05f97ea"]]
when I try to use a lookup ref based on a uuid. It’s weird because ti’s working fine from the repl, it looks like somehow the uuid object or whatever is being interpreted as the macro and the actual value Here’s the snippet
(d/transact! @conn [
                        [:db/add group-id :group/subgroups [[:group/id newgroupid]]]
After doing some more investigation, it seems like it only happens if you try do an ‘array add’. If I just do :db/add group-id :group/subgroups [:group/id newgroupid]] it seems to be fine

yannvahalewyn23:11:30

If you want to do an array add, you should have a transaction-element per added fact, eg:

[[:db/add group-id :group/subgroups [:group/id groupid1]
 [:db/add group-id :group/subgroups [:group/id groupid2]
 ...]
Or use the :db/add map syntactic sugar:
[{:db/id group-id :group/subgroups [[:group/id group1] [:group/id group2]]
which should flatten to the above (not tested)