Flutter firestore复合查询

Jor*_*ira 3 dart firebase flutter google-cloud-firestore

我想知道是否有办法在Flutter中查询firebase firestore集合,为查询添加多个字段.我尝试了一些方法,但我没有意识到如何做到这一点.例如:

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

col.where('nome', isEqualTo: 'Tyg');
col.where('valor', isLessThan: '39');
Run Code Online (Sandbox Code Playgroud)

请有人有办法做到这一点吗?我是新的扑克而不是顺便说一句.

Fra*_*len 10

构建Firestore查询遵循"构建器模式".每次调用where它都会返回一个新的查询对象.所以你编写的代码构造了两个查询,你没有分配给任何东西.

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

Query nameQuery = col.where('nome', isEqualTo: 'Tyg');
Query nameValorQuery = nameQuery.where('valor', isLessThan: '39');
Run Code Online (Sandbox Code Playgroud)