按文档引用过滤 Firestore

Firestore filtering by document reference

我正在尝试通过 React Native 中的文档引用进行过滤。我正在使用 react-native-firebase。我想要字段 (DocumentReference) 在提供的数组中的所有文档:

 const subscriber = firestore()
        .collection('strategyCounts')
        .where(
          'strategy',
          'in',
          user.strategies.map(strategy => {
            return strategy.path;
          }),
        ).onSnapshot(...)

user.strategies 看起来像这样 ["/strategies/id", "/strategy/id2"]

如果要按文档引用过滤,需要在数组中传递DocumentReference个对象。所以像:

  user.strategies.map(strategy => {
    return firestore().doc(strategy.path);
  }),

或(稍短):

  user.strategies.map(strategy => firestore().doc(strategy.path)),