Fork me on GitHub
#datalevin
<
2022-09-06
>
kokonut13:09:33

Hi, I wanted to write a function that finds data (using datalevin as a document store now) by db/id. But below code doesn't seem to work, which I don't understand why. Can someone give me some clue.

(defn find-obj-by-db-id [conn db-id]
  (ffirst
   (d/q '[:find (pull ?e [*])
          :in $ ?dbid
          :where
          [?e :db/id ?dbid]]
        (d/db conn)
        db-id)))

Huahai04:09:20

?e is the entity id. You don't need :db/id

Huahai04:09:01

If you know the entity id, just pull it, no need for a query