google-cloud-node

Getting entity's id inside a transaction

别等时光非礼了梦想. 提交于 2019-12-11 03:47:46
问题 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