Pulling entity id directly instead of map

I have an entity id which has an attr :x/places which is a db.type/ref

pull query goes as
(d/pull (d/db conn) '[:db/id :x/places ....some-other-keys] 01100001)

which returns
{:x/places [{:db/id 01110010}] ..some-other-kvs}

Is there an idiomatic way to get only eid’s for an attr while others keep their spec?
we can obviously transform after getting data from the pull but is there something that can be done on the query level itself?

Also consider that these type of query will be used more commonly and would love to keep the code simple.

1 Like

I felt the need for this quite often, especially in tests or interactive exploration sessions.
Since the introduction of the :xform option to the pull syntax (https://docs.datomic.com/on-prem/pull.html#xform) I can imagine providing a helper function for this purpose or simply allowing any keyword (or vector of keywords?) to be the parameter of :xform. Then you can simply write pull patterns like this: [[:some.ref/attr :xform :db/id]].

1 Like

Another idea, which can ease this pain would be to use https://github.com/redplanetlabs/specter to retouch the returned data by raising the :db/ids out of their maps. It’s more compact and easier to extend than a pure, clojure.core based logic.

1 Like