I'm trying to filter by document reference in React Native. I'm using react-native-firebase
. I want all documents whose field (DocumentReference) is in the provided array:
const subscriber = firestore()
.collection('strategyCounts')
.where(
'strategy',
'in',
user.strategies.map(strategy => {
return strategy.path;
}),
).onSnapshot(...)
user.strategies
looks like this ["/strategies/id", "/strategy/id2"]
CodePudding user response:
If you want to filter by document reference, you need to pass DocumentReference
objects in the array. So something like:
user.strategies.map(strategy => {
return firestore().doc(strategy.path);
}),
Or (slightly shorter):
user.strategies.map(strategy => firestore().doc(strategy.path)),