On Fri, 23 Dec 2011 11:47:38 +0100 Jo-Erlend Schinstad <joerlend.schins...@gmail.com> wrote:
JS> For quite some time, I've been thinking about creating a Gtk TreeModel JS> that uses CouchDB as a backend. I've just started investigating it and JS> I've found some issues I don't know how to solve. I think this would JS> be useful for all kinds of trees, though, so it wouldn't be specific JS> to GTK. I hope someone can help. JS> The general idea is simple. The tree consists of nodes that can have JS> zero or one parent and zero or more children. So I thought each node JS> would be its own document with an ID like [model number, root node JS> number, child node number, child...], for instance, JS> { "_id":[0, 0, 1,2] } would be the third child of the second child of JS> the first root node in the first model. This way, it would be easy to JS> get a single node or a range of nodes (including children) from a JS> specific model. How big is this document? If it's like the TreeModels I've used, maybe you can simply keep the whole connectivity data (the edges of the graph) in one document, and the nodes have one document each. That way you can load or update the graph in one shot; replication is simpler; consistency is better (at worst, a node is missing). Renumbering is easier as well, since you just load a single document, rewrite it, and save. If this is a huge tree or you expect multiple clients to update the connectivity graph this is not a great solution. Ted