首页 文章

Flutter firestore复合查询

提问于
浏览
0

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

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

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

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

1 回答

  • 4

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

    CollectionReference col = Firestore.instance
        .collection("mycollection");
    
    Query nameQuery = col.where('nome', isEqualTo: 'Tyg');
    Query nameValorQuery = nameQuery.where('valor', isLessThan: '39');
    

相关问题