On Thu, Aug 5, 2010 at 11:36, Panop S. <[email protected]> wrote:
> Hi,
>
> My system have document like this
>
> id = 1
> nickname = A
>
>
> id = 2
> parent id = 1
>
>
> id = 3
> parent id = 1
>
>
> id = 4
> parent id = 1
>
>
> Now I use map function to emit ( nickname, doc) so the request
> come from the key of nickname and
> I make another request to get all child which has (id = parent id ).
>
I think with those documents it is not possible. You have a few choices.
1. Make multiple requests like you are doing now
2. If you know the nickname when you *store* document 2, 3, 4, etc. then add
the nickname to that document too. For document 1, you would emit([nickname,
false], doc) and the others would emit([nickname, true]). Query for
startkey=[nickname] endkey=[nickname, {}]. You will get all documents about
nickname. Since "false" comes before "true" in a sort, the parent document
will always be first, and the other documents will be next.
--
Jason Smith
Couchio Hosting