javascript - 为什么这些查询独立工作而不是一起工作?

标签 javascript firebase vue.js google-cloud-firestore

我有 2 个查询想要在我的 Firestore 集合中使用。

这 2 个示例有效:

database
  .collection('servicebonnen')
  .where('medewerker', '==', 'CEES')

和:

database
  .collection('servicebonnen')
  .where('date', '>', this.today)
  .where('date', '<', this.tomorrow)

为什么像这样组合这些不起作用?:

database
  .collection('servicebonnen')
  .where('medewerker', '==', 'CEES')
  .where('date', '>', this.today)
  .where('date', '<', this.tomorrow)

最佳答案

firestore doc here 中所述:

You can also chain multiple where() methods to create more specific queries (logical AND). However, to combine the equality operator (==) with a range or array-contains clause (<, <=, >, >=, or array_contains), make sure to create a composite index.

所以你需要创建composite index在你的情况下。

关于javascript - 为什么这些查询独立工作而不是一起工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55462255/

相关文章:

javascript - 将图像序列绑定(bind)到滚动事件

javascript - 从源代码解析javascript变量

javascript - 在 Mounted() 中运行循环时浏览器卡住

javascript - 如何使用 Bootstrap 横幅验证文本框

android - Firebase 作为 Android 应用后端

android - 身份验证后在 Firestore 中查询 uid 文档 => IllegalStateException

java - 如何获取在 firebase Messages 节点发送给我的最后一条消息?

vue.js - Volar(vscode扩展): line comment syntax in . vue文件模板部分错误

javascript - VueJS 2 模板

javascript - 自推对象构造器