couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <>
Subject Re: view sorting and group question?
Date Mon, 22 Jun 2009 09:16:26 GMT
On Sun, Jun 21, 2009 at 10:15:31AM +0800, hhsuper wrote:
> but if i need to use the view as a datasource to the web page, i need change
> to right view to query on every sorting?

That's one way.

Another way is a single large view where you label each ordering of keys:

function(doc) {
  emit(["by_foo",||null,||null, doc.baz||null]);
  emit(["by_bar",||null, doc.baz||null,||null]);
  emit(["by_baz", doc.baz||null,||null,||null]);

Then your client can query

where the by_foo can be chosen dynamically based on a parameter when
fetching the web page. This may or may not simplify your code, and this one
view might be larger than three separate views.


View raw message