I am trying to add a query where I have two array-contains, which turned out not going to work as Firebase doesn't support it.
const initialQuery = Firebase.firestore.collection('class')
.orderBy('createdAt', 'desc')
.where('access.readAccess.classrooms', 'array-contains', id)
.where('keywords', 'array-contains', keyword)
.limit(5);
So I ended up writing something like below.
const initialQuery = firebase.firestore().collection('class')
.orderBy('createdAt', 'desc')
.where(`accessibleUsers.${id}.hasAccessTo.classrooms.read`, '==', true)
.where('keywords', 'array-contains', keyword)
.limit(5);
Now the issue goes while trying to index this data I see the index is happing only for a particular id. And after seeing a few answers in StackOverflow I am bit confused with the whole indexing.
Based on this, Indexing unknown nodes in Firebase it is saying remove the .where(`accessibleUsers.${id}.hasAccessTo.class.read`, '==', true) and add a rule to firebase security rules to read only where he has access to?
How do I fix this? Any help is appreciated.
from How to index firebase data for firestore query based on dynamic keys?
No comments:
Post a Comment