i am dynamically generating where clause and it is working fine . referring to this solution : Firestore query Cursors Generating Dynamic Queries
function buildQueryNew(collectionRef , whereClauses , _limit) {
let q = query(
collectionRef,
...whereClauses.map((clause) =>
where(clause[0], '==', clause[1])),
limit(_limit)
)
return q;
}
But when i am adding the orderBy Clause it is not working .
function buildQueryNew(collectionRef , whereClauses , sortField,sortOrder , _limit) {
let q = query(
collectionRef,
...whereClauses.map((clause) =>
where(clause[0], '==', clause[1])),
orderBy(sortField,sortOrder),
limit(_limit)
)
return q;
}
Also i have seen if i remove the whereClause map then orderBy is working fine, its like they both are not working together , anything wrong i am doing ?
whereClause Sample: [ [ "name", "himanshu" ] ]
Screenshot below for database :