我只是在寻找在 Firestore 上设计数据库的答案。
我有根集合的第 4 层和第 5 层子集合,在该层上是否可以轻松应用和查询聊天系统?
最佳答案
实时数据库的节点数限制为 32 个。然而,在 Firestore 中,情况要好得多。根据文档:
Documents in subcollections can contain subcollections as well, allowing you to further nest data. You can nest data up to 100 levels deep.
所以深度限制为 100 级。您可以在子集合中包含最多 100 层深度的子集合。如果您不知道子集合如何工作,这里还有另一句话:
Subcollections allow you to structure data hierarchically, making data easier to access.
如果您想了解有关限制或 Firestore 数据模型的更多信息,请查看此处的文档:https://firebase.google.com/docs/firestore/data-model
至于你的问题:
I have subcollections at 4 and 5 levels from root collection and at this level can the chat system be applied and queried easily or not?
是的,您可以查询该信息。当然,使用 Firestore,这些查询速度非常快。但是您需要考虑到数据嵌套太深会影响查询的速度(因为查询的速度没有人会注意到某些东西,它基本上就像皮秒;您只能在运行查询基准测试时才能注意到精度很高)。请注意,查询速度并不取决于请求数据的大小,而是取决于返回数据的大小。
关于java - 我们可以在 Firestore 中查询多深?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57519342/