Closed idhowardgj94 closed 1 year ago
You are right! Queries are not lazy, but d/datoms
is. It’s way faster, too. You can use (d/datoms db :aevt <attr>)
go get all entities with specified attribute, then drop/take resulting collection. See https://docs.datomic.com/on-prem/query/indexes.html#datoms-api and https://docs.datomic.com/on-prem/clojure/index.html#datomic.api/datoms
Thx for kindly reply. I've test datom api, now I'm wondering about how to get other attributes in a entity?
I'm not sure if my understanding is right, but I think that an entity may contains several attributes and value, and while I use datom :aevt I only get the attribute I select. Is there any way can I use, like query base on datom result? Or there is other way to achieve this job
See pull
, esp. pull-many
https://docs.datomic.com/on-prem/query/pull.html. There’s also entity API https://docs.datomic.com/on-prem/overview/entities.html
solved by using @tonsky's suggestion
;; :word is the attribute I selected
(->> (d/datoms (get-ds-db) :aevt :word)
(take 10)
(map :e)
(#(d/pull (get-ds-db) '[*] (first %))))
As title, I'm trying to adopt datascript to my practice frontend project, and use it as an in-memory database in the browser,
Just wonder how to implement pagination using datascript? seems that the query result is not lazy collections, I think that performance would be suck if I just use cljs function like drop / take