如何获取 Datastore 实例的 location/region

How to get the location/region of an Datastore instance

要调用 Datastore.export() API,我需要提供与我正在导出的数据存储位于同一区域的 GCS 存储桶名称。

我检查了 node.js' @google-cloud/datastore Datastore 个实例似乎没有 .location 属性 或类似的东西。此外,Google 提供的其他语言的 Datastore 库似乎缺少此功能。

对于其他 Google API,您通常有办法获取资源的位置。例如。在 GCS 中:Storage().bucket('mybucket').getMetadata().location -> 'EU'.

How to view Google Cloud Datastore Region 显示以手动方式获取此信息,但我正在以编程方式访问。

Firestore 有一个 database get method(截至 2021 年 12 月 23 日的预览版),您可以使用它来查找数据库的位置。 API 还会告诉您数据库的模式(Firestore 本机模式与数据存储模式)。