且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Firestore:多个条件where子句

更新时间:2022-03-11 18:13:15

正如您在API文档中看到的那样, collection()方法返回 CollectionReference 。CollectionReference扩展了查询 Query.where() Query.orderBy()也会返回Query对象。所以你可以像这样重写你的代码:

As you can see in the API docs, the collection() method returns a CollectionReference. CollectionReference extends Query. Query.where() and Query.orderBy() also return Query objects. So you can rewrite your code like this:

var query = firebase.firestore().collection("book")
query = query.where(...)
query = query.where(...)
query = query.where(...)
query = query.orderBy(...)
query.get().then(...)

现在你可以放入条件来确定你想在每个阶段应用哪些过滤器。

Now you can put in conditionals to figure out which filters you want to apply at each stage.