feat(query): in and array-contains-any operators
harrisonlo opened this issue · comments
What is the feature?
Firebase team just introduced in
and array-contains-any
2 days ago!
https://firebase.googleblog.com/2019/11/cloud-firestore-now-supports-in-queries.html
Do you have thoughts/examples on how the feature would be used (i.e. API)?
https://firebase.google.com/docs/firestore/query-data/queries#in_and_array-contains-any
Thanks for posting, this is already supported since queries are passed directly though!
You would do it like so within a component (if you are using react-redux-firebase's hooks):
function SomeComponent() {
useFirestoreConnect([
{
collection: 'projects',
where: ['shared-with', 'array-contains', '123abc']
}
])
// Get projects from redux state
const projects = useSelector(state => state.firestore.ordered.projects)
// ... rest of component
}
If not using hooks you would do the following:
firebaseInstance.setListeners([
{
collection: 'projects',
where: ['shared-with', 'array-contains', '123abc']
}
])
Same thing with the in
operator. To be sure, I tested within the complete example project, but reach out if things aren't working as expected.