且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以在Cloud Firestore中查询多个文档子集合?

更新时间:2023-02-14 10:03:19

查询针对单个文档集合运行。 (当前)无法跨多个(子)集合进行查询。

A query runs against a single document collection. There is (currently) no way to query across multiple (sub)collections.

这意味着您可能希望将用户文档保留在顶层 documents 集合,其UID具有所有者属性。然后,您可以选择带有简单 documentsRef.where( owner, ==,uid)的用户帖子。

That means you'll probably want to keep the user documents in a top-level documents collection, with a owner property for their UIDs. Then you can select a user's post with a simple documentsRef.where("owner", "==", uid).