gpt4 book ai didi

mongodb - 文件夹结构的 NoSQL 模式

转载 作者:行者123 更新时间:2023-12-04 05:51:16 25 4
gpt4 key购买 nike

我有代表文件夹结构的文档。一个文件夹可以包含其他文件夹(嵌套),理论上无限层级深度但更现实的是我们的应用程序有 3 或 4 层。我需要能够检索单个项目(一个节点),也许嵌入会使这项任务有点困难?

有什么建议吗?

最佳答案

The docs对在 mongodb 中存储分层数据的更流行/常见的方法进行了很好的总结。

Embedding documents - 有明显的缺点

  • Hard to search
  • Hard to get back partial results
  • Can get unwieldy if you need a huge tree. Further there is a limit on the size of documents in MongoDB – 16MB in v1.8 (limit may rise in future versions).

因为您需要能够检索单个项目 - 这不是可能是您用例的最佳选择。

Array of ancestorsmaterialized path可能更适合您所描述的内容 - 您可以选择使用 _id 的完整文件路径,因为它是唯一的,并且您希望更常见地查找数据的路径。

关于mongodb - 文件夹结构的 NoSQL 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10008825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com