Fork me on GitHub
#datalevin
<
2022-07-12
>
roklenarcic12:07:51

What’s the main entity ID? :db/id or :db/ident ?

roklenarcic13:07:48

I’m having a bit of an issue with clear command:

(d/clear conn)
Execution error (ExceptionInfo) at datalevin.client/normal-request (client.clj:338).
Request to Datalevin server failed: "No implementation of method: :clear-dbi of protocol: #'datalevin.lmdb/ILMDB found for class: datalevin.storage.Store"

Huahai15:07:01

Thx, I will look into it

roklenarcic07:07:20

BTW I see some functions require that you pass instance of ILMDB, how do I get one from connection? e.g. get-range requires one

Huahai19:07:40

KV and datalog are different API, I do not expect one to access the underlying kv stores of a datalog DB

roklenarcic19:07:16

oh didn’t realize I was calling the wrong function

Huahai22:08:27

this is fixed

roklenarcic14:07:42

Another weird behaviour I’ve seen:

(d/q '[:find (pull ?e [*]) :in $ :where [?e]] (d/db conn))
=> ([{:db/id 14, :name "Rok"}])

;; now I retract attribute via entity
(-> (d/entity @conn 14) d/touch (dissoc :name))
=> {:name "Rok", :db/id 14, :<STAGED> {:name [{:op :dissoc}]}}

;; and I do a transact
(d/transact! conn [*1])
=> {:datoms-transacted 1}

;; 1 datom was affected, I would expect the data to be gone, but it isn't
(d/q '[:find (pull ?e [*]) :in $ :where [?e]] (d/db conn))
=> ([{:db/id 14, :name "Rok"}])

;; but if I just do the same thing a second time, the data is gone
(-> (d/entity @conn 14) d/touch (dissoc :name))
=> {:db/id 14, :<STAGED> {:name [{:op :dissoc}]}}
(d/transact! conn [*1])
=> {:datoms-transacted 0}
(d/q '[:find (pull ?e [*]) :in $ :where [?e]] (d/db conn))
=> ()

Huahai19:07:19

Dissoc on entity is not the way to retract things.

roklenarcic19:07:44

I assumed that it staged retractions

roklenarcic19:07:13

what is the prefered way to delete an entity?

Huahai19:07:44

(d/transact! conn [[:db.fn/retractEntity entity-id]])

Huahai19:07:29

The same as datascript and datomic