CouchDB 中的树
我是 CouchDB 新手,有一个问题。
我正在使用父消息的 ID 作为属性来保存消息。 消息还可以有一个 childMessage 作为父级,因此它看起来像一棵树。
我如何查询所有孩子,包括孩子的孩子?
谢谢
I'm new to CouchDB and have a question.
I'm saving messages with the ID of the parent message as an attribute.
A message can also have a childMessage as parent, so it looks like a tree.
How can i query all childs including the childs of the childs?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是处理分层数据时常用的方法: http: //probouslyprogramming.com/2008/07/04/storing-hierarchical-data-in-couchdb/
This is the commonly used method when dealing with hierarchical data: http://probablyprogramming.com/2008/07/04/storing-hierarchical-data-in-couchdb/
CouchDB 最适合处理非规范化数据。您应该考虑尽可能地对数据进行反规范化。也许您可以将整个树存储为单个文档?
例如:
CouchDB works best with the de-normalized data. You should consider de-normalizing your data as much as possible. Maybe you may store the whole tree as a single document?
E.g.: