I'm using react-native-firebase. I have an array of document id's, and I need to query the associated documents by that array of id's.
我用的是Reaction-Native-Firebase。我有一个文档ID数组,我需要通过该ID数组查询相关的文档。
I can do something like this:
我可以这样做:
firestore().collection('Foo').doc('myDocId').get();
to get a single document by id, but I don't want to iterate through the list and query each one individually. However, I can't figure out how to query the collection by a list of document id's. What I'd really like to do is something like:
通过id获取单个文档,但我不想遍历列表并逐个查询每个文档。但是,我不知道如何通过文档id列表来查询集合。
firestore().collection('Foo').where('id','in',['myDocId1','myDocId2','myDocId3']).get();
however, this doesn't work (probably because 'id' is not actually a field in the documents, but rather the actual id of the document). How do I write an equivalent query against the collection's document id's?
然而,这并不起作用(可能是因为‘id’实际上不是文档中的一个字段,而是文档的实际id)。如何针对集合的文档ID编写等价的查询?
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!