Fork me on GitHub
#datalevin
<
2023-05-30
>
J16:05:01

Hi guys! I play with the server mode and I need confirmation about (def db (d/db conn)) The db is updated when a transact occur, right?

Huahai16:05:40

yes. d/db call checks last-updated timestamp of the remote DB, and compare with the local cache.

J16:05:58

In my example:

(d/transact! conn [{:db/id -1 :pokemon/name "..."}])

conn

(def db (d/db conn))

db

(d/q '[:find ?name
       :where [?e :pokemon/name ?name]]
      db)
If I transact multiple times without reevaluate db I get all my data when I query the db.

Huahai16:05:48

you don’t want to bind db to a var

Huahai16:05:14

as i said, the update is done by the d/db call

Huahai16:05:33

unless you don’t care if you have stale data

J16:05:13

Got it! Last confirmation: When a client make a transaction, the conn of the other client reflect the change?

Huahai16:05:54

this is done lazily. only updated when the client try to do anything.

Huahai16:05:57

so the answer is yes, but not in the way you describe

J16:05:57

Ok I see. Thanks for the clarification. The server mode is very cool!