asami

2022-07-16T11:10:27.873449Z

Next thing, still trying to make a mental map of IDs in Asami. Always worried I’m asking too dumb questions, so please tell me to go read whatever or something if that’s the case 🙂 My testcase:

(def test-data-9 [{:db/ident :id/a-100 :name "my name" :type "something"}
                    {:db/ident :id/a-101 :name "second name" :type "something" :likes :id/a-100}])
  (def transact-info @(d/transact conn {:tx-data test-data-9}))
  (p/clear)
  (tap> (d/export-data conn))

  (d/q '[:find ?node101 ?node100 ?name :where [?node101 :likes ?node100] [?node101 :name ?name]  ] conn)

2022-07-16T11:12:16.325519Z

The query gives:

[:a/node-26957 :id/a-100 "second name"]

2022-07-16T11:14:15.991759Z

And my question - why do I get the node ID and why do I get the :id ? I would naively assume it would pick the same attribute. 🙂

Jakub Holý (HolyJak) 2022-07-16T20:31:29.527109Z

Well, it looks like the value in :likes :id/a-100 ins not interpreted as an ID referring to another entity but just as a keyword. I think you would need either {:db/ident :id/a-100} or [:db/ident :id/a-100] , do not remember now.

2022-07-17T20:03:57.792919Z

Thanks!

2022-07-17T21:28:28.433259Z

I had somehow managed to not pick up on how to create relationships correctly. Thanks again, you got it right 🙂