After I run a transaction in datomic to insert a value, how I can use the return value of the transaction to get the ids of any entities that were created?
Here is a sam
Use d/resolve-tempid. If you were to transact a single entity, looking at :tx-data
would work but if your transaction contained more than one entity, then you wouldn't know the order in which they appear in :tx-data
.
What you should do is give temporary ids to your entities (before transacting them) using either (d/tempid)
or its literal representation #db/id[:db.part/user _negativeId_]
and then use d/resolve-tempid
to go from your temporary id to the real id given by the database. The code would look something like:
(d/resolve-tempid (d/db conn) (:tempids tx) (d/tempid :db.part/user _negativeId_))
For a full code sample, see this gist.