couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Clary <>
Subject Re: Using List to filter data
Date Tue, 01 Feb 2011 12:41:29 GMT
On 2/1/11 3:14 AM, George Burt wrote:
> Is
>     row = getRow()
>     send(JSON.stringify(row));
> the best way to just pass the json through to the browser?  It gets a little
> messy with the commas, but is no big deal.
> And, what is the best way to pass data from the url to a list function?  I
> am trying to use the list as a secondary filter. So I am looking for
> something that will be ignored by the view (or possibly seen and then
> embedded in the emit ... nah, probably not.) or perhaps an array that has an
> extra value that the view doesn't need but that can be seen by the list.

I just use another parameter separate from the startkey, endkey etc., e.g.

&filter={"start_date_type": "after","start_date":"2011-01-30"}

and in the list function:

   if (req.query.filter) {
     try {
       filter = JSON.parse(req.query.filter);
     catch (ex) {
       send('Error parsing filter: ' + ex);

then test each row against the filter's properties to decide whether to 
include it in the list results or not.

View raw message