This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-31
Channels
- # announcements (22)
- # asami (19)
- # aws-lambda (4)
- # babashka (42)
- # beginners (43)
- # calva (28)
- # cider (1)
- # clerk (79)
- # clj-kondo (12)
- # clojure (47)
- # clojure-berlin (1)
- # clojure-brasil (1)
- # clojure-dev (12)
- # clojure-europe (40)
- # clojure-nl (2)
- # clojure-norway (5)
- # clojure-uk (3)
- # clojurescript (56)
- # clr (12)
- # conjure (8)
- # cursive (4)
- # datomic (32)
- # dev-tooling (6)
- # exercism (1)
- # fulcro (9)
- # hoplon (3)
- # jobs (3)
- # jobs-discuss (4)
- # lambdaisland (3)
- # leiningen (1)
- # london-clojurians (1)
- # lsp (125)
- # malli (31)
- # matcher-combinators (3)
- # nrepl (1)
- # off-topic (6)
- # pathom (39)
- # re-frame (13)
- # releases (2)
- # remote-jobs (1)
- # sci (7)
- # shadow-cljs (117)
- # sql (6)
- # squint (7)
- # tools-build (15)
- # tools-deps (12)
When you call asami.core/transact
(or asami.core/transact-async
) then the argument can be:
• a seq of triples to be inserted
• a map
If it’s a map, then the accepted keys are:
• tx-data
: a seq of :db/assert
and :db/remove
statements
• tx-triples
: like the non-map version, a seq of triples to be inserted
• executor
: a user supplied executor. Defaults to the Clojure Agent executor
• input-limit
: limits the maximum number of triples that can be inserted in this transaction (I recommend never using this. It was a UI hack for Cisco)
• update-fn
: a Graph update function.
You want to pass update-fn
This is a function that accepts a graph, and returns a graph. The Graph protocol is found in asami.graph/Graph
You can do a resolve-triple
for something like [the-entity :count ?c]
and then:
(graph-transact graph [[the-entity :count (inc c)]] [[the-entity :count c]])
So:
(asami.core/transact my-connection
{:update-fn
(fn [graph]
(let [c (ffirst (asami.graph/resolve-triple graph :my-entity :count '?c))]
(asami.graph/graph-transact graph [[:my-entity :count (inc c)]] [[:my-entity :count c]])))})
Thank you! "possible" is great!
When I get to SPARQL, then this is something I’ll have a query language to do for you. I just need more weekends. Well… weekends when the kids don’t need me
Hey 🙂 out of interest, have you seen that there's the basics of an "RDF" module in XT which reuses the RDF4J parser and compiles a small subset of SPARQL into XT's public query API? See https://github.com/xtdb/xtdb/blob/master/labs/rdf/src/xtdb/sparql.clj It's mainly been used for benchmarking with https://dsg.uwaterloo.ca/watdiv/ (etc.). Just thought I'd mention it just in case it helps for some inspiration or at least ideas about what not to do with your hypothetical weekends!
Time for a little bit of personal philosophy: There is lots of work out there that I could be leveraging to help build out Asami faster. I really ought to. But I choose not to for a few reasons: • I try to keep the dependencies very minimal. This has proven to be very useful. • Each thing I implement myself is a learning experience. I appreciate this. • Most external systems are not Clojure/ClojureScript compatible. I’m also hoping to incorporate ClojureCLR support soon. It would be even cooler if I can make it work with ClojureDart or (eventually) Jank. I admit that there’s a certain amount of hubris/ego happening here. But it’s my hobby, so I’m allowed do it the way I’d like.
Also, I tend to be a little opinionated. It’s nice to have an environment where I get to express that
That last one is the most flexible though. I will often look back at something I wrote and realize that my position has evolved, and I wouldn’t do it like that anymore 🙂
Years ago (like 12), I tried an RDF/XML parser, but the Clojure XML parser didn’t handle namespaces! I did try patching it, but I probably used non-idiomatic Clojure back then, and it was rejected. So I stopped. But it’s since been fixed, so I should try again.