couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Taras Puchko <taras.puc...@gmail.com>
Subject Re: Rewrite a URL segment into a parameter with JSON string encoding
Date Tue, 07 Sep 2010 18:13:10 GMT
The docs [1] state that the key must be a proper URL encoded JSON value,
so _view/by-tag?key=java won't work, but _view/by-tag?key="java" will.

[1] http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options

Cheers,
Taras


On Tue, Sep 7, 2010 at 8:18 PM, Benoit Chesneau <bchesneau@gmail.com> wrote:
>
> On Tue, Sep 7, 2010 at 5:56 AM, Taras Puchko <taras.puchko@gmail.com> wrote:
> > Hello,
> >
> > I'm trying to use a URL segment as a key for a view, like the following:
> > {
> >  "from": "/tags/:tagname",
> >  "to": "_view/by-tag",
> >  "query": {"key": ":tagname"}
> > }
> >
> > The problem is that the key have to be JSON-encoded, which complicates my
> > API. Every client has to know how to JSON-encode strings.
> >
> > However, I have found a workaround. If I use arrays for my keys the
> > following works:
> > {
> >  "from": "/tags/:tagname",
> >  "to": "_view/by-tag",
> >  "query": {"key": [":tagname"]}
> > }
> >
> > I'm wondering if there is a more efficient solution for this problem.
> >
> > Thanks,
> > Taras
> >
>
> The key doesn't need to be json encoded only url encoded. If not let me know.
>
> - benoit

Mime
View raw message