繁体   English   中英

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)),

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM