什么构成了 Firestore 中的写入操作?

What constitutes a write action in Firestore?

我目前正在使用 Firestore 开发 Flutter Web 应用程序以实现数据持久性。该应用程序未投入生产,因此我是唯一访问此后端的人。只有一个包含单个文档的集合,具有许多嵌套字段(6 层深)。我从 https://firebase.google.com/docs/firestore/pricing 中了解到,阅读是按文档计算的,所以每次我重新加载我的应用程序时,它都应该算作一次阅读,但在我今天开始工作后的最后 4 个小时里,我已经达到了 1.7K 次阅读(如使用选项卡中所报告)。我知道我没有多次重新加载应用程序,也没有多次调用集合的隐藏循环。 这是调用 Firestore 的 Flutter 代码:

final sourceRef=FirebaseFirestore.instance.collection("source");
var data=await sourceRef.doc("stats").get(); 

请问我错过了什么?

根据 Firebase 定价,写入定义为:

You are charged for each document read, write, and delete that you perform with Cloud Firestore. Charges for writes and deletes are straightforward. For writes, each set or update operation counts as a single write.

意思是创建一个文档就是一次写入。如果稍后更新同一文档,则 Firebase 将其计为一次写入。

这里有一个更详细的 table,您可以将其用于 billing, and an example

建议在 Firebase 控制台的许多产品的“使用情况”选项卡中查看单个产品的使用情况,因为这可以缩小导致您看到的使用量增加的产品范围。

我强烈建议您将 write and view logs 添加到您的申请中;这样,您就可以监控有多少写入和读取。