From user-return-7590-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Fri Nov 13 09:06:50 2009
Return-Path:
Delivered-To: apmail-couchdb-user-archive@www.apache.org
Received: (qmail 44250 invoked from network); 13 Nov 2009 09:06:50 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3)
by minotaur.apache.org with SMTP; 13 Nov 2009 09:06:50 -0000
Received: (qmail 69382 invoked by uid 500); 13 Nov 2009 09:06:49 -0000
Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org
Received: (qmail 69307 invoked by uid 500); 13 Nov 2009 09:06:49 -0000
Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: user@couchdb.apache.org
Delivered-To: mailing list user@couchdb.apache.org
Received: (qmail 69297 invoked by uid 99); 13 Nov 2009 09:06:49 -0000
Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Nov 2009 09:06:49 +0000
X-ASF-Spam-Status: No, hits=4.0 required=10.0
tests=MSGID_MULTIPLE_AT,SPF_PASS,WEIRD_QUOTING
X-Spam-Check-By: apache.org
Received-SPF: pass (nike.apache.org: local policy)
Received: from [89.36.166.90] (HELO mail.ro1-jdhosting.net) (89.36.166.90)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Nov 2009 09:06:38 +0000
Received: from LygosPC ([82.77.219.6]) by ro1-jdhosting.net with MailEnable ESMTP; Fri, 13 Nov 2009 11:05:47 +0200
From: "Sebastian Negomireanu"
To:
Subject: Hierarchical documents query question
Date: Fri, 13 Nov 2009 11:07:20 +0200
Message-ID: <005701ca6440$b4d14aa0$1e73dfe0$@negomireanu@justdesign.ro>
MIME-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: AcpkQLSwzuV0zdRjSxCns4GV/os/yA==
Content-Language: en-us
X-ME-Bayesian: 0.000000
X-Virus-Checked: Checked by ClamAV on apache.org
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:
function(doc){
emit(doc.path,null);
}
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
sebastian.negomireanu@justdesign.ro
SC JustDesign SRL | Str. Dorului 20, 550352, Sibiu, Romania
+40-269-210008 | office@justdesign.ro | www.justdesign.ro
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.