Flutter firestore compound query

拈花ヽ惹草 提交于 2020-06-14 06:16:04

问题


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.


回答1:


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');


来源:https://stackoverflow.com/questions/50316462/flutter-firestore-compound-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!