You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by George Burt <im...@gmail.com> on 2011/02/01 12:14:00 UTC

Using List to filter data

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.

Thanks,

George

Re: Using List to filter data

Posted by George Burt <im...@gmail.com>.
Very cool.  Thanks Bob.

On Tue, Feb 1, 2011 at 7:41 AM, Bob Clary <bo...@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

Re: Using List to filter data

Posted by Bob Clary <bo...@bclary.com>.
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.