Fork me on GitHub
#datomic
<
2022-08-26
>
nando09:08:44

To confirm what I think I understand from the docs, a transaction to update 2 different entities is possible and would look like this. What I’m doing here is essentially marking the batch item as complete or fulfilled and subtracting the batch weight from the stock.

(defn save-batch-item
  [m]
  (d/transact conn {:tx-data [{:db/id (:id m)
                               :batch-item/weight (:weight m)
                               :batch-item/complete? (:complete? m)}]
                              [{:db/id (:nid m) 
                               :nutrient/grams-in-stock (:new-grams-in-stock m)
                               }]
}))

favila09:08:16

Yes. Transaction data is a list of commands of the form [op arg ,,,]. Maps are just syntax sugar for the equivalent [:db/add entity attr value]. Transaction functions are just commands that expand to other commands in the transactor. Expansion continues until a set point of only primitive :db/add or :db/retract commands are left.

favila09:08:50

Given this model, there are no meaningful entity “boundaries” to transactions. It’s just commands.

👍 1
nando10:08:19

@U09R86PA4 👍 Thanks for the confirmation!

Antoine Zimmermann15:08:03

hello, i'm looking into datomic using postgres storage for my next project and i noticed that the version of the jdbc driver mentioned in the docs is quite old, does it works still use the latest version? Edit: it works locally using md5 pwd encryption with pg:latest and driver 42.5.0 Edit 2: using a PG14 self managed DB (scaleway) it works using datomic-pro-1.0.6397, openjdk 8 and pg driver 42.5.0