datahike

erre lin 2025-07-30T16:33:58.769799Z

Hi team, I’m reading through the api cljdoc but get a bit confused about conn and db. For example: In the entry for datoms, the example code there uses db

(d/transact db [{:db/id 5 :name "Oleg"}
{:db/id 5 :likes "candy"}
{:db/id 5 :likes "pie"}
{:db/id 5 :likes "pizza"}])
In the entry for transact, it uses conn instead:
;; add a single datom to an existing entity (1)
(transact conn [[:db/add 1 :name "Ivan"]])
Can I assume they are the same and I should use conn whenever possible, as suggested in the entry for db :
(db conn)
Returns the underlying immutable database value from a connection. Exists for Datomic API compatibility. Prefer using @conn directly if possible. As there is a mixed use of conn and db through the doc, should I use just conn in most cases (say, read from and write to the db)?

alekcz 2025-07-30T17:30:49.623639Z

@conn equivalent to (db conn) this what you use for querying or reading. The whenever you transact use conn

šŸ‘ 2
alekcz 2025-07-30T18:13:04.669449Z

@errelinaaron ā˜ļø