This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-02
Channels
- # beginners (118)
- # boot (73)
- # cider (2)
- # cljs-dev (65)
- # cljsrn (18)
- # clojure (49)
- # clojure-argentina (4)
- # clojure-italy (19)
- # clojure-portugal (1)
- # clojure-russia (1)
- # clojure-spec (34)
- # clojure-uk (102)
- # clojurescript (202)
- # code-reviews (3)
- # core-async (5)
- # cursive (11)
- # datomic (25)
- # emacs (1)
- # graphql (22)
- # hoplon (6)
- # keechma (59)
- # leiningen (10)
- # luminus (31)
- # lumo (78)
- # off-topic (141)
- # om (32)
- # om-next (2)
- # onyx (6)
- # parinfer (55)
- # pedestal (3)
- # protorepl (3)
- # re-frame (8)
- # reagent (8)
- # ring-swagger (1)
- # rum (20)
- # specter (1)
- # sql (5)
- # test-check (11)
- # vim (13)
- # yada (7)
Hi everyone, we need to implement an auto-increment attribute, what are good patterns in datomic to do so?
@U6H375J4T using a transaction function. The Datofu library provides an implementation, which you may use or take inspiration from https://github.com/vvvvalvalval/datofu#generating-unique-readable-ids
great, thank you
it's not possible to go back and add :db.part/tx
metadata to a transaction, correct?
realized this when attempting transactions with assertions plus tx metadata in the :db.part/tx
partition, and noticing that if the assertion was already true, the tx metadata was not added
so, iiuc: if i want to put tx metadata (aka reified transactions) on a specific existing EAV the V must change. otherwise the assertion is ignored.
@devth you can annotate transactions after the fact; simply use its real id instead of a tempid
ie by querying [_ _ _ this]
in datalog
@robert-stuttaford ah, makes sense!
:db.part/tx will always reference the in-flight transaction
literally did this today š had to yank some scheduled mails, and forgot to document the ad-hoc transaction, so i had to find it and annotate it afterwards
awesome. yeah i was relying on the :db.part/tx
referencing in-flight txes bit but hadn't considered looking up the tx-id after the fact
if i have: [[?p :user/first-name ?fn][?p :user/last-name ?ln]]
and I want to bind the concatenation of ?fn
and ?ln
to ?name
, how would i go about doing that
[[?p :user/first-name ?fn] [?p :user/last-name ?ln] [(clojure.core/str ?fn " " ?ln) ?name]]
possibly
@kennethkalmer no need to prefix str
either
even better
wasnāt sure if clojure.core
was available, so thought Iād be safe š
@kennethkalmer yeah I just checked the doc to be sure; I had a doubt too š
howzit everyone, I need to ask some advice on how to save a bunch of derived transactions to Datomic. Some background first: I have this abstraction of a data-set, which has a beginning and end date, and a type. these are prepopulated and saved to Datomic. Then I process a ton of other entities and calculate a bunch of derived entities from different entities. this is all simple and well, but I need to āinjectā some additional transactions into the mix based on the transactions Iāve seen pass by alreadyā¦
By means of example, lets say I see the following (abbreviated) transactions pass by: [{:db/id -1 :foo/id 1} {:db/id -2 :foo/id 2} {:db/id -3 :foo/id 1}]
, I wanna concat onto that list [{:db/id 1 :data-set/ids [n m]} {:db/id 2 :data-set/ids [m]}]
(where n & m are other eids).
You see, nowhere else are entities 1 or 2 referenced in the transactions, so Iām thinking Iād need a transducer that accumulates the seen references to them and build up the additional transactions to concat onto the list. If I just slot them in directly as I encounter my ref Iāll get an exception of trying to update the same entity twice in one transaction.
My list of transactions also needs to be lazy, or Iāll run out of memory. The list ends up in a generic function that batches the transactions.
Iāve already played with a simple transducer that simply counts the elements in a list and appends that number to the final results and it seems to work nicely when combined with sequence
.
Thing is, I just donāt know how to best handle this situation (even battling with some missing vocabulary here). Hope this rambling makes sense
now Iām wondering two things, 1) a reducing function that returns larger outputs than inputs is probably a smell, and 2) if this couldnāt be reworked with core.async to be more fluid
@kennethkalmer I am pretty sure a reduce function which returns a large output than input is not a smell
think iāll spend a bit of time wrapping my head around http://docs.datomic.com/best-practices.html#pipeline-transactions and core.async. maybe I can come up with something simpler while hopefully getting some feedback here