This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-28
Channels
- # announcements (2)
- # babashka (15)
- # beginners (13)
- # chlorine-clover (17)
- # cider (14)
- # clj-kondo (1)
- # cljfx (3)
- # clojure (21)
- # clojure-australia (2)
- # clojure-europe (3)
- # clojure-nl (4)
- # clojurescript (25)
- # core-async (7)
- # cursive (8)
- # datomic (4)
- # defnpodcast (17)
- # events (1)
- # honeysql (5)
- # jobs-discuss (18)
- # pathom (8)
- # polylith (6)
- # reagent (2)
- # reveal (1)
- # shadow-cljs (2)
- # spacemacs (12)
- # tools-deps (13)
- # xtdb (2)
Is it possible to add data to an edge/relation? I know that I could annotate the type of relation by designating it in the property of the document doing the reference eg:
:person/friends [:johnny]
But this starts to become impractical when the type of relation isn’t known up front. Eg a generic post
or entry
that maps relationships to entities of different contexts.
Is it possible to add meta data?
:entry/refs [{:edge "eats" :ref :pizza} {:edge "friend" :ref :johnny} {:edge "reading" :ref :lord-of-the-ringns]
;;as opposed to
:entry/eats [:pizza]
:entry/reads [:lord-of-the-rings]
:entry/friends [:johnny]
The latter is impractical from an application point of you. Or maybe I’m just thinking about this wrong?
I believe you can do this in datomic with tuples, but I haven’t worked with itOne thing you can do is add an entity with an ID that corresponds to the edge, such as with map IDs, like :crux.db/id {:e :some-e :a :entry/refs :v :pizza}
you can then add the edge data to that document. Constructing the maps in Datalog isn't pleasant but works. Alternatively you could consider pulling the edges out to be first-class entities with UUID IDs, with a pair of directed references like :from :some-e :to :pizza