# The use of d/tempid

**URL:** <https://forum.datomic.com/t/the-use-of-d-tempid/815>\
**Category:** General\
**Created:** [January 31, 2019, 12:41am UTC](https://forum.datomic.com/t/the-use-of-d-tempid/815 "2019-01-31T00:41:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blake](https://avatars.discourse-cdn.com/v4/letter/b/a9a28c/32.png) [@blake](https://forum.datomic.com/u/blake)\
**Post date:** [January 31, 2019, 12:41am UTC](https://forum.datomic.com/t/the-use-of-d-tempid/815/1 "2019-01-31T00:41:48Z")

</div>

In a lot of tutorials, I see tempid being used where it seems to serve no purpose. [Here](http://gigasquidsoftware.com/blog/2015/08/15/conversations-with-datomic/)’s an example from a friendly walkthrough:

```auto
(d/transact conn [{:db/id (d/tempid :db.part/user)
                   :owner/name "Bob"
                   :owner/dogs [{:db/id (d/tempid :db.part/user)
                                 :dog/name "Fluffy"

```

Every time we create a new entity, the example shows :db/id being manually generated. If I take out those lines all the examples still work. It seems like you’d use a temp ID if you were building a transaction where you were creating multiple entities with one transaction, but you weren’t, for whatever reason nesting them (as Gigasquid does in the linked examples).

I see at some point that one _couldn’t_ leave these out and so maybe I’m just looking at old examples. Or is there some magic behind that :db.part/user segment that I’m overlooking?

---

<div class="post-metadata">

**Author:** ![juskrey](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/juskrey/32/130_2.png) [@juskrey](https://forum.datomic.com/u/juskrey)\
**Post date:** [January 31, 2019, 7:05am UTC](https://forum.datomic.com/t/the-use-of-d-tempid/815/2 "2019-01-31T07:05:54Z")

</div>

tempid is no longer required and now can be a string. See the changelog and [https://docs.datomic.com/on-prem/transactions.html](https://docs.datomic.com/on-prem/transactions.html)  
Generally you want to have explicit tempid if you have to obtain the newly created entity id(s) after the transaction (from :tempids and maybe following the query on :db-after) or refer it within the transaction, otherwise it can be skipped.

---

<div class="post-metadata">

**Author:** ![marshall](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/marshall/32/48_2.png) [@marshall](https://forum.datomic.com/u/marshall)\
**Post date:** [January 31, 2019, 4:06pm UTC](https://forum.datomic.com/t/the-use-of-d-tempid/815/3 "2019-01-31T16:06:28Z")

</div>

That is correct.  
Implicit tempids were added in version 0.9.5530 ([https://docs.datomic.com/on-prem/changes.html#0.9.5530](https://docs.datomic.com/on-prem/changes.html#0.9.5530)).  
As blake noticed, you can still use them without any issue, but they’re no longer required.

---

<div class="post-metadata">

**Author:** ![dustingetz](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/dustingetz/32/56_2.png) [@dustingetz](https://forum.datomic.com/u/dustingetz)\
**Post date:** [January 31, 2019, 4:31pm UTC](https://forum.datomic.com/t/the-use-of-d-tempid/815/4 "2019-01-31T16:31:58Z")

</div>

Marshall, can you confirm that for OnPrem, d/tempid despite being optional is still useful in the circumstances described here: [https://docs.datomic.com/on-prem/indexes.html#partitions](https://docs.datomic.com/on-prem/indexes.html#partitions)

---

<div class="post-metadata">

**Author:** ![marshall](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/marshall/32/48_2.png) [@marshall](https://forum.datomic.com/u/marshall)\
**Post date:** [January 31, 2019, 4:45pm UTC](https://forum.datomic.com/t/the-use-of-d-tempid/815/5 "2019-01-31T16:45:01Z")

</div>

That is also correct Dustin.
