我具有以下firebase结构:
{
"company1": {
"name": "Company One","invoices": {
"invoice1": {
"amount": 300,"currency": "EUR","timestamp": 1572608088
},"invoice2": {
"amount": 460,"timestamp": 1572608088
}
}
}
}
也就是说:
我有一个收藏集companies
。
每个公司都有一个文件。
每个公司都有一个子集合invoices
。
每张发票都具有属性amount
,currency
,timestamp
。
是否存在一种有效的方法来获取公司所有发票的总金额,而无需从Firestore提取所有相关文档? 这是我想出的方法,效率很低:
this.afs.collection('companies').document('company1').collection('invoices',ref => ref.where('timestamp','>',1556710488).where('timestamp',1572953978))
由于请求的时间段未知,我不能仅仅使用云函数来增加值。