flutter - 在 Flutter 中,如何使用 .where 来检查字段是否在本地列表中?
问题描述
我正在尝试加载 QuerySnapshot 但过滤字段“f_ID”是否在本地列表中。如果是,请不要添加它。
但是使用 .where 我无法访问我的本地列表对象。有什么办法吗?
List<Map> the_List = new List();
// map elements format: {'f_ID': xxxx, 'date': xxxx}
// date is irrelevant to this search
QuerySnapshot querySnapshot = await Firestore.instance
.collection('Queue')
.orderBy('clo_Score')
.limit(25)
.where("f_ID" ??????)
.getDocuments();
解决方案
用于检索文档列表的 .where 查询用于过滤您可以检索的文档。
它允许您将参数与相等的、或多或少的条件和其他一些条件进行比较。
在此处阅读有关 Firestore 查询的更多信息https://firebase.google.com/docs/firestore/query-data/queries
如果你想检查一个 id 是否在你的 LOCAL 列表中已经检索到,你应该使用数据库查询的结果 => QuerySnapshot。
querySnapshot.data.documents.where((doc)=> doc['f_ID'] == null)
推荐阅读
- .net - Bamboo 单元测试集成错误:CORBA 连接失败,次要代码为 4000
- mysql - MySQL加入2个表错误的输出..值相乘
- typescript - 从受约束的泛型参数中提取数据属性名称
- reactjs - React:将状态或数据从父组件传递到对象中的子组件
- html - fa 图标被 Disqus 评论计数覆盖
- reactjs - 如何使用 React 测试库测试选择选项逻辑
- postgresql - 如何替换 postgresql 数据中的文本?
- nixos - 如何在 NixOS 中安装 unison-gtk?
- ios - SwiftUI 选择器中选定选项的值不会更新视图
- reactjs - 即使已定义属性,也无法读取未定义的属性“标题”