You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Jens Alfke <je...@couchbase.com> on 2013/03/08 21:14:52 UTC

Can filter parameter values be arbitrary JSON or just strings?

[I have a feeling I’ve asked this before, but I can’t find any record of it in my email archives, and if I’d gotten an answer I’d probably have incorporated it into the wiki. So here goes. Apologies if this is a dup.]

Are the query parameters to filter functions allowed to have arbitrary JSON values (i.e. arrays or objects) or just strings? Replication docs and the runtime filter-function API both allow for non-strings, but the parameters end up getting converted into URL query parameters to a _changes feed request, and the only examples I can find of them do _not_ put quotes around string values. That implies they’re not JSON.

For example, <http://guide.couchdb.org/draft/notifications.html#filters> says
> If you now run a request adding a ?name=Steve parameter, the filter function will only return result rows for documents that have the name field set to “Steve.”

If the parameter were interpreted as JSON, it would need to be encoded as “?name=%22Steve%22”.

—Jens

PS: This came up in the form of a TouchDB issue, <https://github.com/couchbaselabs/TouchDB-iOS/issues/239>