【问题标题】:where to define datastore-indexes.xml in nodeJS project hosted on compute engine?在计算引擎上托管的 nodeJS 项目中在哪里定义 datastore-indexes.xml?
【发布时间】:2016-01-23 13:34:42
【问题描述】:

我们在计算引擎上托管一个 NodeJS 应用程序,它使用 gcloud-node 连接到谷歌数据存储。 简单查询运行良好,但具有多个选择的复杂查询给出“412:前置条件失败”错误。更多详情请访问“: Multiple select in google datastore query throwing ApiError: Precondition Failed error in node

我知道这个错误是因为我没有配置 datastore-indexes.xml。作为 GCP 世界的新手。你能帮我在哪里定义我的项目中的 datastore-indexes.xml 文件。

【问题讨论】:

标签: node.js google-compute-engine google-cloud-datastore gcloud-node


【解决方案1】:

您还可以使用gcloud preview app 工具和an index.yaml file 来指定索引策略。

例如,如果您需要用户索引和 LoginTimes 时间戳:

indexes:
 - kind: LoginTimes
   properties:
   - name: user
   - name: timestamp
     direction: desc

【讨论】:

  • 请注意,对于生产用途,您可能希望手动更新数据存储索引,而不是每次都自动上传index.yaml。特别是: 1) 更新索引可能需要一些时间,因此您可能希望在您的应用之前上传新索引。 2)如果您使用多个模块,它们都共享相同的数据存储和索引,因此您可能希望将数据存储配置保留在例如一个单独的目录。
猜你喜欢
  • 2016-07-06
  • 1970-01-01
  • 1970-01-01
  • 2021-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多