incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson" <jch...@grabb.it>
Subject Re: How to use View URL Query Parameters?
Date Sun, 20 Jul 2008 20:30:33 GMT
Avi,

Try this:

function(doc) {
  doc.tags && doc.tags.forEach(function(tag){
    emit(tag,null);
  });
}

and read this: http://wiki.apache.org/couchdb/ViewCollation

one query can pull out all view rows with the tag you use as the key param.

Chris

On Sun, Jul 20, 2008 at 4:24 PM, Avi Flax <avif@arc90.com> wrote:
> Specifically, I don't understand how to use "key".
>
> Let's say I want to get all Comment documents which are tagged with "doofus".
>
> I figured I'd create a "views" key in a design doc that looked
> something like this:
>
> {
>   "for_tag":
>   {
>       "map": "function(doc) { if (doc.tags.indexOf(key) != -1)
> emit(null, doc) }"
>   }
> }
>
> and then GET this URL:
> http://couchdb:5984/blog/_view/comments/for_tag?key=%22doofus%22
>
> But it's returning 0 rows. I know I must be missing something here.
>
> Apologize if this is a FAQ or is just so obvious it doesn't even need
> to be. I think perhaps I need to take a break from the computer for a
> couple of hours.
>
> Thanks,
> Avi
>
> --
> Avi Flax » Lead Technologist » Partner » Arc90 » http://arc90.com
>



-- 
Chris Anderson
http://jchris.mfdz.com

Mime
View raw message