【问题标题】:Why firestore multiple whereEqualTo are not working为什么firestore多个whereEqualTo不起作用
【发布时间】:2019-07-04 16:07:02
【问题描述】:

我有一个这样的文档集合:

shiftId: {
    open: boolean,
    terminalId: string,
    startDate: Date
}

我创建了一个这样的索引:

我的代码查询如下所示:

            shiftCollection
                .whereEqualTo("open", true)
                .whereEqualTo("terminal", "1")
                .orderBy("startDate", Query.Direction.DESCENDING)
                .limit(1)
                .get()
                .addOnSuccessListener {
                    if (it.isEmpty){
                        Log.d(TAG, "There is no open shift")
                        return@addOnSuccessListener
                    }

                    .......
                }

并且可以肯定我至少有一个文档匹配过滤条件:

然而查询总是返回空

提前致谢。

【问题讨论】:

  • 请附上你整个数据库结构的截图,并注明shiftCollection是如何初始化的?

标签: kotlin google-cloud-firestore


【解决方案1】:

您正在查询terminal,但您的数据库中的实际键是terminalId

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-22
    • 1970-01-01
    • 2020-01-07
    • 2019-02-05
    相关资源
    最近更新 更多