我有以下数据结构:
collection/
parent_document_1/
timestamp: 0
subcollection/
document/
belongsTo: parent_document_1
data: data
parent_document_2/
timestamp: 0
subcollection/
document/
belongsTo: parent_document_1
data: data
parent_document_3/
timestamp: 0
subcollection/
document/
belongsTo: parent_document_1
data: data我想按parent_documents属性对timestamp进行排序,然后对subcollection集合进行collectionGroup查询。我不想向documents添加额外的属性,因为timestamp值在parent_documents下是我想要排序的唯一值。原因是documents可以彼此复制,timestamp需要为每个parent_document单独更新。
更大的情况是,我希望能够查询,比如说,只有3-5最新更新的subcollections。
这有可能与Firestore有关吗?
发布于 2020-10-13 02:37:52
除了将时间戳复制到要查询的子集合中的文档之外,您别无选择。
使用Firestore时,当查询集合或集合组时,只能在这些集合的文档中立即使用字段。您可以在其他集合中使用文档中的not reach字段--这包括“父”文档和“子”文档。不同集合中的文档之间没有类似SQL的“联接”。
https://stackoverflow.com/questions/64327657
复制相似问题