【发布时间】:2021-08-04 04:17:45
【问题描述】:
我有一个查询,应该(应该)获取所有“DateLive”小于今天和“DateEnds”大于今天的文档。所以文档是“活的”,还没有“结束”。
这是我的 Dart 查询...
final todayAM = RepoUtil.todayTime000001();
final todayPM = RepoUtil.todayTime235959();
final querySnapshot = await _db
.collection('things')
.where('deleted', isEqualTo: false)
.where('datelive', isLessThan: todayAM)
.where('dateends', isGreaterThan: todayPM)
.where('localzips', arrayContainsAny: localZips)
.limit(100)
.get();
final thingsJson = querySnapshot.docs.map((doc) => doc.data()).toList();
return thingsJson.map((thingJson) => Thing.fromJson(thingJson)).toList();
当我运行应用程序时,我得到了这个错误,我理解,但不知道如何解决......
I/flutter (1781): ThingView ERROR ThingListError([], 'package:cloud_firestore/src/query.dart': 断言失败: line 484 pos 18: 'hasInequality == field': All where filters不等式( 或 >=)必须在同一个字段上。但您在“FieldPath([datelive])”和“FieldPath([dateends])”上有不等式过滤器。).error
如何编写这个 Firestore 查询?
感谢您提供的任何帮助:-)
【问题讨论】:
标签: flutter dart google-cloud-firestore