incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <>
Subject Re: Trees and leaf nodes
Date Mon, 01 Feb 2010 11:04:48 GMT
On Mon, Feb 01, 2010 at 05:43:29PM +1100, Patrick Barnes wrote:
> It looks messy if the node has a little 'expand' icon next to it,
> though - but there are no actual children below it. Is it possible
> to create a view that will emit as value whether each node has
> children?

I think the client needs to make two queries. Under a given node:

1. Get the list of the children
2. Determine whether each child also has children

You can do (2) using a single multi-key query, e.g.

  {keys:[c1, c2, c3, ...]}

Using your existing view you'll get all the grandchildren, which you
probably don't care about but can just check whether there are any or not.

To reduce the size of the returned data you could make a grouped query
instead.  With a suitable reduce function on your view, then you could get
back a count of the number of children for each child, which might be useful
to display in your UI anyway.



View raw message