GQL nodejs 库 get(keys) return 结果中的键名

GQL nodejs library get(keys) return key name in results

我目前正在使用带有键列表的 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 匹配,因为在视觉上它们似乎与传入的键的顺序不一致?

因此,为了获取密钥,我只需要从我的 results 对象中获取特定实体并获取 [datastore.KEY] 属性

例如

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

其中 datastore = require('@google-cloud/datastore')();

https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1724