【发布时间】:2021-01-05 01:39:19
【问题描述】:
我正在尝试在 node.js 应用程序中使用 google firestore。我从一个简单的用户身份验证开始,寻找具有给定 ID 的用户:
const query = datastore.createQuery('users').filter('googleId', '=', googleId)
const [result] = await datastore.runQuery(query)
这一行总是抛出异常
Error: 9 FAILED_PRECONDITION: no matching index found.
尽管有文档,但并未建议如何解决此问题。
此查询在数据存储模拟器中有效,但模拟器随后不建议索引。
当我尝试在云控制台中对该属性添加索引时,控制台坚持认为它已经作为默认索引存在,显然不是这样。
如何查询 Cloud Datastore 中的简单属性?
【问题讨论】:
-
这很奇怪。我在我的测试项目中使用了它并且运行良好。也许您应该尝试新的新项目...?
-
您的数据库是处于 Firestore 本机模式还是 Datastore 模式。如果它处于本机模式,则需要使用 Firestore 客户端库而不是 Datastore 库。
标签: node.js google-cloud-platform google-cloud-datastore