datascript

Jonas Rodrigues 2025-10-09T00:54:58.606829Z

I'm implementing a custom NATS-based IStorage for Datascript and noticed that -store is always called, even when no data was actually transacted (`:tx-data` is an empty vector). To avoid this, I wrapped d/transact! as follows:

(defn transact-not-empty! [conn tx-data]
  (let [tx-data (:tx-data (d/with @conn tx-data))]
    (when (seq tx-data)
      (d/transact! conn tx-data))))
This works in my tests, but I’m wondering if there’s any hidden downside. Is this a safe approach, or is there a better way to suppress -store when there’s no effective transaction data?

Niki 2025-10-09T12:30:48.052029Z

I think it should be safe, can even put this check somewhere in Datascript itself, maybe after original tx data is expanded? PR?

Jonas Rodrigues 2025-10-09T15:16:47.582639Z

Sure https://github.com/tonsky/datascript/pull/492 :)