Node.js GQL nodejs库get(键)在结果中返回键名

Node.js GQL nodejs库get(键)在结果中返回键名,node.js,google-cloud-datastore,google-cloud-platform,gql,Node.js,Google Cloud Datastore,Google Cloud Platform,Gql,我目前正在使用NodeJS数据存储库执行一个带有键列表的批处理GQL查询 datastore.get(keys).then((results) => { // Tasks retrieved successfully. console.log("results", JSON.stringify(results)); res.send() }); 例如,如果我的密钥ID为1,2,3,4 当我得到我的结果时,我想要 [ {1: {key:value}}, {2: {key:value

我目前正在使用NodeJS数据存储库执行一个带有键列表的批处理GQL查询

datastore.get(keys).then((results) => {
// Tasks retrieved successfully.
console.log("results", JSON.stringify(results));

res.send()
});
例如,如果我的密钥ID为1,2,3,4

当我得到我的结果时,我想要

   [ {1: {key:value}}, {2: {key:value}},{3: {key:value}},{4: {key:value}}]
而现在我只是

   [ {key:value}, {key:value},{key:value},{key:value}]

所有结果都已成功返回,但不会随结果一起返回ID。是否需要检索id作为结果的一部分,以便我知道哪些结果与哪个id匹配,因为它们看起来不符合传入的键的顺序?

因此,为了获取键,我只需要从我的
结果
对象中获取特定实体并获取[datastore.key]属性

e、 g

其中
datastore=require('@googlecloud/datastore')()

 let entity = results[0];
 let key = entity[datastore.KEY];