[Vuejs]-Filter Firestore with multiple where not working

0👍

CollectionReference extends Query. The result of where() is a new Query:

Creates a new query that returns only documents that include the
specified fields and where the values satisfy the constraints
provided.

You need to retain the result Query if each where() and use it for the get(). Something like this:

filterResult(){
    let self = this;
    let query = wall;

    if(self.filterLocation!=""){
        query = query.where('location','==', self.filterLocation);
        console.log("Location flag");
    }
    if(parseInt(self.filterMaximumPrice)!=0){
        query = query.where('price','<', parseInt(self.filterMaximumPrice));
        console.log("Price flag");
    }

    query.get()
    .then(snapshots => {
        snapshots.forEach(doc => {
        self.listFilteredWall.push(doc.data());
        }, this);
    })
}

Leave a comment