本文介绍了在Flutter上进行Firestore查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在FlutterFire中使用.where()对Firestore执行查询?因为文档和示例未涵盖此内容,所以我感到困惑.我在这里还没有找到其他问题,所以希望我不要重复.
How can I use the .where() in FlutterFire to perform queries for Firestore? Because the docs and example doesn't cover this I'm confused. I haven't found other questions on this here so I hope I'm not asking duplicate.
推荐答案
下面的示例遍历集合字段"中的每个文档,并根据"grower"进行过滤.没有关于它的文档,但是您可以检查源代码.
Example below go through every document in the collection 'fields', and filter on 'grower`. There is no documentation on that, but you may check the source code.
import 'package:cloud_firestore/cloud_firestore.dart';
Firestore.instance.collection('fields').where('grower', isEqualTo: 1)
.snapshots().listen(
(data) => print('grower ${data.documents[0]['name']}')
);
从源代码:
Query where(
String field, {
dynamic isEqualTo,
dynamic isLessThan,
dynamic isLessThanOrEqualTo,
dynamic isGreaterThan,
dynamic isGreaterThanOrEqualTo,
bool isNull,
}) {..}
这篇关于在Flutter上进行Firestore查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!