How to perform collection group query using document ID in Cloud Firestore

前端 未结 1 833
面向向阳花
面向向阳花 2020-11-29 08:15

So few day ago I moved my apps posts to cloud firestore from realtime database because of the more flexable querying that firestore apparently has. I have been modifying my

相关标签:
1条回答
  • 2020-11-29 08:54

    This is currently not possible with collection group queries. You might be tempted to put a filter on the query for FieldPath.documentId() == 'your-doucment-id', but that just isn't supported. FieldPath.documentId() is actually a token that refers to to fully unique document id, which includes the entire path of the document.

    The workaround is to store the document ID as a field in the document, and filter on the contents of that field instead. So, if the document had a field called id with the ID of the document, you could query for collectionGroup("Likes").whereEquals('id', 'your-document-id').

    0 讨论(0)
提交回复
热议问题