# Pulling entity id directly instead of map

**URL:** <https://forum.datomic.com/t/pulling-entity-id-directly-instead-of-map/1554>\
**Category:** Datomic Pro\
**Created:** [July 30, 2020, 5:51pm UTC](https://forum.datomic.com/t/pulling-entity-id-directly-instead-of-map/1554 "2020-07-30T17:51:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhinav](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@abhinav](https://forum.datomic.com/u/abhinav)\
**Post date:** [July 30, 2020, 5:51pm UTC](https://forum.datomic.com/t/pulling-entity-id-directly-instead-of-map/1554/1 "2020-07-30T17:51:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![onetom](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/onetom/32/430_2.png) [@onetom](https://forum.datomic.com/u/onetom)\
**Post date:** [September 4, 2020, 3:04am UTC](https://forum.datomic.com/t/pulling-entity-id-directly-instead-of-map/1554/2 "2020-09-04T03:04:08Z")

</div>

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](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]]`.

---

<div class="post-metadata">

**Author:** ![onetom](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/onetom/32/430_2.png) [@onetom](https://forum.datomic.com/u/onetom)\
**Post date:** [September 4, 2020, 3:12am UTC](https://forum.datomic.com/t/pulling-entity-id-directly-instead-of-map/1554/3 "2020-09-04T03:12:01Z")

</div>

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