incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebastian Negomireanu" <>
Subject Hierarchical documents query question
Date Fri, 13 Nov 2009 09:07:20 GMT
Hi all,

I need some advice on how to handle querying some documents. I assume that
this might be a very straightforward question, but I'm stuck at this point.
Basically my database contains files and folders in a hierarchical
structure. A simplified version of my documents looks like this:

Doc: {
_id: "....",
_rev: "....",
Path: ["","folderA","folderB",...,"folderX"]

Basically the Path property contains an array representing the directories
that make up the path to the folder. Now comes the question. I need to get
all folders that have a certain parent path. I've been thinking to
accomplish this using a map function like:


Now, my problem is how to use the startkey & endkey to get the subfolders.
For example, if I have three folders, let's say /folder/subfolderA,
/folder/subfolderB and /folder/subfolderA/bar, my view would look like this:

["","folder","subfolderA"] => id1
["","folder","subfolderB"] => id2
["","folder","subfolderA","bar"] => id3

Let's say I want to get the root folder children (only one level). I've
tried using startkey=[""]&endkey=["",""] but it returns everything.
Simmilar, to get the first level under /folder, I've tried using
startkey=["","folder"]&endkey=["","folder",""], but again it returns also
the /folder/subfolder/bar item.

I don't want to get the entire tree, only one level at a time. So how can I
accomplish this?

Best regards,
Sebastian Negomireanu | CTO / Managing Partner JustDesign Sibiu, Romania
+40-726-181186 | +40-788-757462

SC JustDesign SRL | Str. Dorului 20, 550352, Sibiu, Romania
+40-269-210008 | | 

The information contained in this e-mail is intended only for the ones to
which it is addressed, and contains information which is confidential and
may be privileged. Unauthorized disclosure, copying or use (of any part) of
this information is prohibited. If you are not the intended recipient,
please notify the sender or Just Design SRL by return e-mail or telephone
(+40-269-210008) and delete this e-mail from your system, including any
attachments thereto. Any information in this message that does not relate to
the official business of Just Design SRL shall be understood as neither
given nor endorsed by it. Internet communications are not secure, therefore
Just Design SRL does not accept any liability for either the contents of
this message, or any damage related to documents and/or data which are
communicated by e-mail. Violation of this notice may be unlawful. 

View raw message