I find myself called (ds/entity ...)
a lot... is there a way to return an entity or a set of entities from a query directly?
@samcferrell you can use pull
in the find specification of a query, for example:
[:find (pull ?e [:artist/startYear :artist/endYear])
:where [?e :artist/name "The Beatles"]]
You can get something similar to ds/entity
by using a wildcard in the pull expression:
[:find (pull ?e [*])
:where [?e :artist/name "The Beatles"]]
Couple differences tho. entity
is lazy, and can be used with functions like get-in
to “walk” edges. pull
is eager, and *
won’t actually bring in the “edge entities” on its own.
@cjsauer thanks for explain in detail! I did not realize that I can use this [:user/id 1]
format as a value! It's this a new feature in recent updates?
@doglooksgood no it isn’t new. Lookup refs are a primary feature, likely inspired by datomic.
You’ll find that quite a bit of the Datomic documentation also applies to DataScript.
@cjsauer thanks!