Flutter Firestore复合查询 [英] Flutter firestore compound query

查看:78
本文介绍了Flutter Firestore复合查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道Flutter中是否有一种查询Firebase Firestore集合的方法,可以在查询中添加多个字段。我尝试了一些方法,但是我不知道该怎么做。例如:

i'd like to know if there's a way to query firebase firestore collection in Flutter adding more than one field to the query. I tried some ways but i didn't realize how to do that. For example:

CollectionReference col = Firestore.instance
    .collection("mycollection");

col.where('nome', isEqualTo: 'Tyg');
col.where('valor', isLessThan: '39');

有人,请问有办法做到吗?

Someone, please, have some way to do that? i am new in flutter and not getting the way.

推荐答案

构建Firestore查询遵循构建器模式。每次调用 where 时,它将返回一个新的查询对象。因此,您具有的代码构造了两个查询,您未分配任何内容。

Building Firestore queries follows a "builder pattern". Every time you call where it returns a new query object. So the code you have constructs two queries, that you don't assign to anything.

CollectionReference col = Firestore.instance
    .collection("mycollection");

Query nameQuery = col.where('nome', isEqualTo: 'Tyg');
Query nameValorQuery = nameQuery.where('valor', isLessThan: '39');

这篇关于Flutter Firestore复合查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆