asami

Macroz 2024-12-04T18:37:26.050619Z

Hi and thanks for making Asami. I've been trying it out today. The documentation is good 👍 I am looking at the options for graph data in Clojure and one of the things that seems more difficult than it needs to be is collection values. My experience in graph data is however limited, so I don't know what the standard experience of thriving in the presence of them is. In my example domain there is a workflow that has handlers who are users who have some details. Now depending on if I need to maintain an order, it can be modeled as a set or has to be e.g. array that preserves the order. I found that Asami handles this and models them internally as linked lists. In practice, there are some bumps in the road that I'll show in example code and I'm curious if you know if the other graph databases (not necessarily in Clojure) handle this better, or if there exists a graph model where collection values are integrated well? I guess from computer/graph science theory point of view they are an uninteresting feature, but in practice at least I am dumping JSON / EDN into graphs and expecting to have an easy and simple developer experience. Sometimes it for example matters, who in a list gets e-mailed first. Any comments on these pieces of code? Anything I should think or read up on? Something silly I'm doing?

;; example data has a bunch of these
{:nickname "The Dev", 
 :user/id "developer", 
 :user/name "Developer", 
 :user/email "", 
 :db/ident "developer"}
...
{:item/archived false, 
 :workflow/type :workflow/default, 
 :workflow/anonymize-handling true, 
 :workflow/licenses [{:db/ident 7} {:db/ident 8}], 
 :workflow/title "Restricted workflow", 
 :workflow/disable-commands [{:disable-command/command :application.command/invite-member} {:when/state [:application.state/returned], :when/role [:applicant], :disable-command/command :application.command/close}],
 :item/enabled true, 
 :workflow/organization {:db/ident "nbn"}, 
 :workflow/handlers [{:db/ident "developer"} {:db/ident "handler"} {:db/ident "rejecter-bot"}], 
 :workflow/id 9, 
 :db/ident 9, 
 :workflow/forms []}
;; tries to join the user email in ANY order with :db/ident
  (d/q '[:find [?user-email ...]
         :in $ ?workflow-id
         :where
         [?workflow :workflow/id ?workflow-id]
         [?workflow :workflow/handlers ?handlers]
         [?handlers :a/contains ?handler]
         [?handler :user/email ?user-email]]
       db
       11)
;; tries to join the user email info in array order
  (->> (d/q '[:find [?handlers ...]
              :in $ ?workflow-id
              :where
              [?workflow :workflow/id ?workflow-id]
              [?workflow :workflow/handlers ?handlers]]
            db
            11)
       first
       (d/entity db)
       (mapv :db/ident)
       (d/q '[:find [?user-email ...]
              :in $ [?user-id ...]
              :where
              [?user :user/id ?user-id]
              [?user :user/email ?user-email]]
            db))

quoll 2024-12-04T19:04:35.531509Z

Hi! I want to let you know that I’ve seen this and want to respond soon, but I’m away from home for the rest of the afternoon and can’t get back to you immediately, sorry

👍 1
Macroz 2024-12-04T19:09:15.155069Z

No problem! There is no rush.