0

我有一组文档 ID。我想使用数组中的 ID 从 firestore 获取这些文档。换句话说,我需要遍历 ID 数组并使用相应的 ID 查询每个文档。

所以目前这就是我查询的方式。我正在查询“属性”集合中的所有文档。

export default compose(
  connect(mapStateToProps, mapDispatchToProps),
  firestoreConnect((props) => {

      if (!props.auth.uid) {
        props.history.push('/signin')
        return []
      }

      return [


        {
          collection: 'Properties',

        },
        {
          collection: 'Properties',
          doc: propid
      },

        {
          collection: 'Partners',
          doc: props.auth.uid,
          subcollections: [{
              collection: 'MyInvites',

            },


          ]
        },
      {
        collection: 'Partners',
        doc: props.auth.uid,
        subcollections: [{
           collection: 'ReceivedInvites',
          }
        ]
      },
      {
        collection: 'Partners',
        doc: props.auth.uid,

      },

      ]


    }
  )

目标是按 ID 从“属性”集合中获取特定文档。我要查询的文档的 ID 在一个数组中。

例如

let idArray=[doc0id,doc1id,doc2id,doc3id,....docnid]

有没有办法做到这一点?

4

1 回答 1

0

您所描述的是一个in查询

因此,对于最多 10 个文档 ID,您可以执行以下操作:

myCollection.where(firestore.FieldPath.documentId(), 'in', ["123","456","789"])
于 2020-04-09T23:49:26.007 回答