在 mongodb 中存储文件系统树并作为 json 提供给 Flex 应用程序
我想在 Ruby 应用程序中将文件系统树存储到 MongoDB 中,因此我们正在讨论类似以下内容的 json/bson 表示形式:
/
/foo
/foo/one
/foo/bar/two
/foo/bar/three
/four
我的目标是高效存储它并通过 json 将其提供给 Adobe Flex 应用程序,该应用程序将在其中显示它一个树组件。
您认为哪个是最好的解决方案?
本文档建议了一些选项。 我想要采用这种格式的第一种模式(请记住 16Mb 文档大小的限制):
{"/" => [{"foo" => ["one", {"bar" => ["two", "three"]}]}, "four"]}
您觉得怎么样?这是存储分层文件系统树的好格式吗?
任何建议表示赞赏。
I want to store a filesystem tree into MongoDB within a Ruby application, so we are talking about json/bson representation of something like:
/
/foo
/foo/one
/foo/bar/two
/foo/bar/three
/four
my aim is to store it efficiently and to serve it via json to an Adobe Flex application which will display it in a Tree component.
which is the best solution in your opinion?
this document suggests some options.
i'd like to go for something like the first pattern (keeping in mind the limit of 16Mb document size) with this format:
{"/" => [{"foo" => ["one", {"bar" => ["two", "three"]}]}, "four"]}
what do you think? is this a good format to store a hierarchical filesystem tree?
any suggestion is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有很多方法可以解决这个问题,但以下是对于 Flex(而不是服务器)来说最简单的解决方案。
在我看来,您发布的示例数据有点奇怪。默认情况下,Flex 树组件接收一个对象(任何类型)并查看其中是否有名为“children”的属性,如果有,则从那里分支出来。
因此,如果您想在树组件中显示该目录结构,您将发送类似于以下内容的 JSON:
有意义吗?
There are many ways to solve this problem, but here is the solutions that will be the easiest for Flex (not the server).
The example data you posted is a bit weird IMO. By default, the Flex tree component takes in an Object (of whatever types) and looks to see if there's a property called 'children' in it, if there is, it branches out from there.
So, if you wanted to display that directory structure in a tree component, you would send a JSON similar to this:
Make sense?