couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From George Burt <imtrues...@gmail.com>
Subject Re: Using List to filter data
Date Tue, 01 Feb 2011 13:31:13 GMT
Very cool.  Thanks Bob.

On Tue, Feb 1, 2011 at 7:41 AM, Bob Clary <bob@bclary.com> wrote:

> 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.
>
>


-- 
George Burt
President
TrueShot Enterprises, LLC.
(386) 208-1309
Fax (213) 477-2195
www.TrueShot.com
12756 92nd Ter
Live Oak, FL 32060

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message