datascript

quoll 2022-01-25T13:58:04.035300Z

I’d rather a query for that, though you’d get :db/id values rather than :id (into {} (q '[:find ?attr ?val :where [?e :id 0] [?e ?a ?val] [?a :db/ident ?attr]] the-db))

Niki 2022-01-25T13:59:51.035400Z

That would work too, although queries are much slower

lilactown 2022-01-25T00:46:59.027900Z

is there a way to quickly lookup an entity via ref like [:id 0] and get a map of all attrs?

lilactown 2022-01-25T17:01:23.035600Z

ah nice, thanks!

Niki 2022-01-25T07:53:55.029800Z

Entities are not well-suited for that type of problem. Better use pull: (d/pull db '[*] [:id 0])

lilactown 2022-01-25T00:47:25.028300Z

I'm running into issues using entity because it doesn't implement empty

lilactown 2022-01-25T00:47:32.028500Z

and I'm trying to walk it

lilactown 2022-01-25T00:48:32.029700Z

it's totally fine if it doesn't resolve references to other entities, as long as it contains the refs. e.g.

{:id 0
 :refs #{[:id 1] [:id 2]}}