简体   繁体   English

在firestore中使用snapshot.count的最有效方法?

[英]Most efficient way to use snapshot.count in firestore?

I have a project storing user response data in firestore, which I want to regularly query to return count results on.我有一个在 firestore 中存储用户响应数据的项目,我想定期查询它以返回计数结果。 ie. IE。 "how many users who chose X also chose Y". “有多少用户选择了 X 也选择了 Y”。 These are all chosen from a collection full of 'per-user' documents that contain their choices.这些都是从包含他们选择的“每个用户”文档的集合中选择的。

The (only) result I want for this usage is the total number of users who meet the condition, which I can get through snapshot.Count .我想要的(唯一)结果是满足条件的用户总数,我可以通过snapshot.Count获得。

But if I have say, 1000 users who all meet the positive condition, does that count as 1000 reads?但是,如果我说,1000 个用户都满足肯定条件,那算作 1000 次阅读吗? If so, is there a way of limiting that?如果是这样,有没有办法限制它? I don't want to read the data, I just want the count...我不想读取数据,我只想计数...

Any steer on this would be really appreciated!对此的任何指导将不胜感激!

Thanks in advance提前致谢

But if I have say, 1000 users who all meet the positive condition, does that count as 1000 reads?但是,如果我说,1000 个用户都满足肯定条件,那算作 1000 次阅读吗?

Yes.是的。

If so, is there a way of limiting that?如果是这样,有没有办法限制它?

No. Firestore doesn't have any aggregation type queries like count, avg, min, max, etc.不,Firestore 没有任何聚合类型查询,如 count、avg、min、max 等。

I don't want to read the data, I just want the count.我不想读取数据,我只想计数。

Then you're going to have to keep a running count of documents (as they are added or deleted) in another document.然后,您将不得不在另一个文档中保持文档的运行计数(当它们被添加或删除时)。 You can read that one document to get the count.您可以阅读该文件以获取计数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Firestore中存储标签的最有效方法是什么? - What is the most efficient way to store tags in Firestore? 在Firebase Firestore中查询帖子的最有效方法 - Most Efficient Way To Query Firebase Firestore For Posts 对于此用例,最有效的 Firestore 模型是什么? - What is the most efficient firestore model for this use case? 对一个或多个 Firestore 集合中的文档进行计数的最有效方法 - Most efficient approach to count documents in one or more Firestore collection(s) 将数据从RecyclerView保存到Firestore(以及多个片段)的最有效方法 - Most efficient way of saving data from RecyclerView into Firestore (and with multiple fragments) Firebase Firestore 快照读取计数 - Firebase Firestore snapshot read count 在 Cloud Firestore 中处理大型集合的过滤和排序的最有效和可扩展的方法是什么? - What's the most efficient and scalable way to handle filtering and sorting of a large collection in cloud firestore? 为了延迟加载和无限滚动(Firebase + React),在 Firestore 中使用多个快照监听器的正确方法是什么? - What is the correct way to use multiple snapshot listeners in Firestore for the purpose of lazy loading and infinite scroll (Firebase + React)? 让 Firestore 快照侦听器更高效地首次加载大量数据? - Making Firestore snapshot listeners more efficient for first loading a lot of data? 从 Firestore 中的多个子集合的多个子集合中获取所有文档的最有效方法是什么? - What is the most efficient way to get all documents from multiple sub-collections of multiple sub-collections in Firestore?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM