It looks like firestore now supports array_contains query functionality:
https://firebase.google.com/support/release-notes/js

This would be super useful for reducing the querying needed. For example if I need to get all the comments for a list of N posts, this would N individual queries. With array-contains, you could get them all in one query!
Hi @davidtlee! We support this already in the query callback.
Hi @davideast, could you give an example or point to documentation?
Using 'array-contains' within the where clause throws the following error:
[ts] Argument of type '"array-contains"' is not assignable to parameter of type 'WhereFilterOp'.
This is the code I'm trying to use with version 5.0.0-rc.11 of angularfire2:
return this.afs.collection('games', ref => {
return ref
.orderBy('timestamp')
.where('playerIds', 'array-contains', uid)
.limit(30);
})
@Matttaylor8910 I had the same issue. Searching does work as David East says, but for some reason the typings weren't correct for me locally. I had to edit the typings file for firebase, then the app started building again.
Open node_modules/firebase/index.d.ts to line 1543 and added 'array-contains' to the type WhereFilterOp.

@davideast thanks! it does look like it works. But I realized I was reading it wrong. I thought array-contains allows passing in an array for matching anything within the array. But I realized it only allows passing in a single value and checking if an array on the backend contains the query item. whoops!
@leonlovett If you update to the latest Firebase version the typings should work
I manage to solve this issue using the following dependencies version
{
// all Angular deps on version 5.0.3
...
"angularfire2": "5.0.0-rc.6",
"rxjs": "5.5.4",
"firebase": "5.3.0",
"@firebase/app": "0.1.10",
...
}
array-contains only work with string?? the examples which are given shows that it works with string but how to deal when array contains objects
/mycollection
/array +{name:'yogi'},
{name:'yogi1'},
{name:'yogi2'}
here how the query will be for object with name==yogi?
this.afs
.collection('userroutes', ref =>
{ return ref.where('mycollection','array-contains','name==yogi') } //where we should put the condtion
)
.valueChanges()
.subscribe(data => {
//data is empty
});
Hi everyone, I just find out that a little different here: array-contains and array_contains

should we update this for consistance @davideast
@hiepxanh for consistency, I think we should update this to array_contains.
array-contains is indeed consistent across platforms only the Python SDK seems to use the underscore version and as well in the docs it's everywhere mentioned with an underscore.
Most helpful comment
Hi everyone, I just find out that a little different here:

array-containsandarray_containsshould we update this for consistance @davideast