CouchRest.post(url, {:keys => keys})

26 views
Skip to first unread message

viatropos

unread,
Jun 25, 2009, 4:50:07 AM6/25/09
to CouchRest
How does that work? What does that URL look like?

When I do:

Project.all(:keys => [keyA, keyB, keyC])

I get a URL, before the CouchRest.post(url, {:keys => keys}) call,
that looks like this:

http://127.0.0.1:5984/simple_test_database/_design/Project/_view/all?include_docs=true&reduce=false

And the payload looks like this:

{:keys=>[keyA,keyB,keyC]}

I don't know anything about complex URLs, so what would that URL look
like?

http://127.0.0.1:5984/simple_test_database/_design/Project/_view/all?include_docs=true&reduce=false&keys=keyA,keyB,keyC

********
The RESULT from the call to:

http://127.0.0.1:5984/simple_test_database/_design/Project/_view/all?include_docs=true&reduce=false

Looks like this:

"{"total_rows":7,"rows":[]}"

Even though there are 7 entries in that view, why are there no
results?

Thanks for your help.

Best,
Lance

candlerb

unread,
Jun 25, 2009, 10:56:50 AM6/25/09
to CouchRest
CouchDB doesn't support multi-key queries embedded into URLs, for the
reason that URLs have a limited length (typically 4K)

> The RESULT from the call to:
>
> http://127.0.0.1:5984/simple_test_database/_design/Project/_view/all?...
>
> Looks like this:
>
> "{"total_rows":7,"rows":[]}"
>
> Even though there are 7 entries in that view, why are there no
> results?

I think there are 7 rows in the entire view, but none of them match
any of the three keys you gave.

Another example: the database 'test' contains 2 documents.

$ curl http://127.0.0.1:5984/test/_all_docs?key=%22garbage%22
{"total_rows":2,"rows":[]}

Anyway, these questions would probably be best asked on the couchdb-
user mailing list, as they're not related to CouchRest.

Mike Papper

unread,
Sep 17, 2014, 1:49:11 PM9/17/14
to couc...@googlegroups.com, b.ca...@pobox.com
I believe CouchDB supports the 'keys' query parameter as POST. the docs seem to indicate it supports it for GEt as well but that never worked for me.

The keys value is a JSON array (of key values).

Mike
Reply all
Reply to author
Forward
0 new messages