I am currently working on an application that requires fetching users based on their preferred preferences, but I am experiencing issues with the sorting feature.
export const fetchUsers = (minAge, maxAge, prefer, gender) =>
db.collection('profiles')
.where('age', '>=', minAge)
.where('age', '<=', maxAge)
//.where('gender', '==', prefer)
.get()
.then(snapshot => snapshot.docs.map(doc => ({id: doc.id, ...doc.data()})))
When I include all three where clauses, it does not return any data. However, if I use only age or gender, the query returns the correct information.
What could be causing the issue of the three where clauses not returning data, and why does it only work when using either age or gender alone?
I attempted to modify the .where clause to .where({...}), but this resulted in incorrect code. Additionally, when trying to filter based on only minimum age and gender, the result was zero data returned, despite expecting at least one user.