首页 > 解决方案 > What exactly is regarded as 'document read' in Cloud Firestore?

问题描述

I did find some posts about how pricing is decided, but I want to make it as clear as possible.

Here's my document structure,

{
 ...
 firstOption: "A",
 secondOption: "B",
 customerID: "1234",
 ...
}

I need to check if any of three conditions is met.

For example, if firstOption is "A", secondOption is "B", or customerID is "1234".

Since Firestore doesn't support OR in where cluase, my current plan is,

db.collection('').get().then(snapshot => snapshot.filter(doc => { 
 const {firstOption, secondOption, customerID} = doc.data();

 if(firstOption === 'A' || secondOption === 'B' || customerID === '1234') 
  return true;
 else 
  return false;    
})

If three documents are returned, is it regarded as reading three documents or, since no where clause is used to filter, reading the entire documents in the collection?

标签: javascriptgoogle-cloud-firestore

解决方案


如果您编写的客户端代码查询一个集合并且不过滤任何文档,它将读取该集合中的每个文档,以便客户端可以访问其所有快照。通常,如果查询与文档匹配,则将其计为读取。


推荐阅读