This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-08
Channels
- # announcements (4)
- # aws (3)
- # babashka (5)
- # beginners (16)
- # cider (8)
- # clj-kondo (3)
- # clojars (8)
- # clojure (115)
- # clojure-uk (15)
- # clojurescript (18)
- # data-science (5)
- # datomic (14)
- # fulcro (49)
- # funcool (6)
- # graalvm (3)
- # graphql (4)
- # lumo (17)
- # malli (5)
- # off-topic (15)
- # reitit (18)
- # ring-swagger (8)
- # rum (2)
- # shadow-cljs (35)
- # tools-deps (18)
- # uncomplicate (2)
- # vrac (1)
i’m curious what kinds of patterns folks do around making tx-data, especially with respect to uniqueness and upserts
it seems like upserts are mostly automatic when you have like {:unique-kw :a, :x 1}
and then later do {:unique-kw :a, :x 2}
i’d love for the same magic when working with tuples. for example, if you were modeling a two-level hierarchy with uniqueness within each branch of the hierarchy: {:top/name :x}
and {:bottom/parent [:top/name :x] :bottom/name :y}
if you do that, but you have unique/identity on :bottom/parent+name
tuple, you get a uniqueness constraint violation when trying to upsert a bottom entity
something like Unique conflict: :bottom/parent+name, value: [12345 :y] already held by: …. asserted for: …
i could create some kind of upsert-by database transaction function, but i’m wondering if folks with more datomic experience have examples, suggestions, ideas, patterns, whatever
ooh, hmm, didn’t realize i could actually add derived tuples as tx data, seems like that works just like a non-tuple attribute for upserts…. that’s nice!
having discovered that - i’m still open to hearing about patterns folks use for building transactions, etc
I’ve used functions that transform transactions to resolve tempids or de-dup upserts to merge data (pre tuples and for other types of uniqueness not supported by datomic). I’m interested in what you find, because it’s a problem I run into a lot
i’m curious if you could say more, b/c that’s basically my current plan: to create a richer language on top of tx-data that basically compiles down to tx-data