Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在查询中使用Firestore多个日期相等时不返回文档_Java_Android_Google Cloud Firestore - Fatal编程技术网

Java 在查询中使用Firestore多个日期相等时不返回文档

Java 在查询中使用Firestore多个日期相等时不返回文档,java,android,google-cloud-firestore,Java,Android,Google Cloud Firestore,因此,我很难让以下查询正常工作: firebaseFirestore.collection("kids") .document(documentID) .collection("books") .whereEqualTo("accountID", accountID) .whereEqualTo("checkoutDate"

因此,我很难让以下查询正常工作:

firebaseFirestore.collection("kids")
            .document(documentID)
            .collection("books")
            .whereEqualTo("accountID", accountID)
            .whereEqualTo("checkoutDate", epochDate)
            .whereGreaterThanOrEqualTo("checkoutDate", firstDayThisWeekDate)
            .orderBy("checkoutDate")
            .orderBy("startTime", Query.Direction.ASCENDING)
            .orderBy("lengthOfTime", Query.Direction.DESCENDING);
epochDate是一个日期对象,设置为1970年1月1日 firstDayThisWeekDate是一个日期对象,它引用本周第一天(星期日)的日历日期

如果我只有两个checkoutDate等式中的一个,那么查询就会起作用。但是如果我把两者结合起来,我得到的结果是零。我错过了什么

这管用

firebaseFirestore.collection("kids")
            .document(documentID)
            .collection("books")
            .whereEqualTo("accountID", accountID)
            .whereEqualTo("checkoutDate", epochDate)
            .orderBy("checkoutDate")
            .orderBy("startTime", Query.Direction.ASCENDING)
            .orderBy("lengthOfTime", Query.Direction.DESCENDING);
firebaseFirestore.collection("kids")
            .document(documentID)
            .collection("books")
            .whereEqualTo("accountID", accountID)
            .whereGreaterThanOrEqualTo("checkoutDate", firstDayThisWeekDate)
            .orderBy("checkoutDate")
            .orderBy("startTime", Query.Direction.ASCENDING)
            .orderBy("lengthOfTime", Query.Direction.DESCENDING);
这管用

firebaseFirestore.collection("kids")
            .document(documentID)
            .collection("books")
            .whereEqualTo("accountID", accountID)
            .whereEqualTo("checkoutDate", epochDate)
            .orderBy("checkoutDate")
            .orderBy("startTime", Query.Direction.ASCENDING)
            .orderBy("lengthOfTime", Query.Direction.DESCENDING);
firebaseFirestore.collection("kids")
            .document(documentID)
            .collection("books")
            .whereEqualTo("accountID", accountID)
            .whereGreaterThanOrEqualTo("checkoutDate", firstDayThisWeekDate)
            .orderBy("checkoutDate")
            .orderBy("startTime", Query.Direction.ASCENDING)
            .orderBy("lengthOfTime", Query.Direction.DESCENDING);
以下是我为图书文档准备的场景。 如果字段“repeats”为true,则签出日期将始终为epochDate 如果字段“repeats”为false,则日期将大于epochDate

我的目标是能够抓取epochDate文档和任何日期在本周第一天或之后的文档

我正努力在一个查询中完成这一点,我想我能做到。我就是不能接受这两个日期的比较。看起来医生说你可以


任何帮助都将不胜感激。

在同一查询中添加
您希望得到什么。whereEqualTo(“checkoutDate”,epochDate)wheregreater than或qualto(“checkoutDate,firstday thiswekdate)
?这个greaterThanOrEqualTo子句有点毫无意义,因为您已经在上面搜索
whereEqualTo
。嗨,托德。非常感谢您的回复。此查询的目标是获取包含纪元日期的文档以及存在于本周第一天或之后的文档。所有日期都应排除在外。如果有一种方法可以使用“repeats”字段组合,我也可以这样做,正如我上面提到的,历元日期总是与repeats==true相关联,我总是希望返回这些文档以及本周第一天的文档。因此,两个日期相等或重复的任意组合都等于true,并且当前周+远期日期都是可以接受的。您基本上描述的是or查询,而这并不是Cloud Firestore真正支持的。我想你最好把它分成两个独立的查询。是的,我很希望避免把它分成两个查询。。没有其他选择了吧?