简体   繁体   English

mongodb:存储分层树结构?

[英]mongodb: storing a hierarchical tree structure?

on the mongodb, how would I go about storing a hierarchical tree data in which each node contains a Java object containing it's own set of string variables and objects? 在mongodb上,我将如何存储分层树数据,其中每个节点都包含一个包含它自己的字符串变量和对象集的Java对象?

If there were no children, it would straight forward. 如果没有孩子,那就会直截了当。 but how would you store a child node DBobject as a field on the mongodb? 但是如何将子节点DBobject存储为mongodb上的字段?

for example on a Jtree, if a user clicks and selects delete on a specific node, there should be some unique identifier that would correspond. 例如,在Jtree上,如果用户在特定节点上单击并选择删除,则应该存在一些对应的唯一标识符。

ps can I create a database for each user and let mongodb authenticate the user? ps我可以为每个用户创建一个数据库,让mongodb验证用户吗?

Kim, You should check out this mongodb article Trees in mongodb . 金,你应该看看这个mongodb文章树在mongodb It might give you some lead. 它可能会给你一些带头。

The document model is JSon so that is a tree structure in itself. 文档模型是JSon,因此它本身就是一个树结构。 You also have option of embedded (arbitrary) links between docs; 您还可以选择在文档之间嵌入(任意)链接; naturally you can compose a directed graph of documents linking to one another. 很自然地,您可以组成一个链接到彼此的文档的有向图。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM