I have a datastore transaction where I create an entity (a user) letting datastore generate the ID for me.
I then would like to use that ID so that I can create another entity (of another kind).
While this is possible with regular datastore 'save' api:
datastore.save(user).then(() => {
userId = user.key.id // returns entity's ID created by datastore
})
However, this does not seem possible when using a transaction:
transaction.save(user).then(() => {
console.log( user.key.id )
})
The above outputs "cannot read 'then' of undefined'", even though there's no callback listed in the docs, i tried anyway.
When creating/saving an entity with a transaction, how can I retrieve that entity's autogenerated ID?