datascript 2025-10-09

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?

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