且构网

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

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

更新时间:2023-02-14 09:50:51

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

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

这意味着您可能希望将用户文档保存在*** documents 集合中,并为其 UID 提供一个 owner 属性.然后,您可以使用简单的 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).