incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jarrod Roberson <jar...@vertigrated.com>
Subject How to do ad hoc where queries in CouchDB
Date Thu, 29 Apr 2010 08:05:07 GMT
I have come up with a technique I have not seen documented anywhere on the
internet.
I want to query documents based on one or more properties at run time that
are dynamic and variable.
For lack of a better example:

SELECT * FROM mytable WHERE col1='A' and col2='B and col3='c'

but imagine that sometimes I only have one or two or no columns to query by,
or 3 or 8
or I want to do WHERE col1='A' and col1='Z'.

Everything I read online said you couldn't do this with CouchDB. And I
really needed this for a project I am working on at work.
Well I turned to what I am calling a Pivot View function and a List function
and got pretty much what I wanted.
A more sophisticated view function and the related doc id / include_docs
feature in 0.11 will let you retrieve documents with properties from other
documents as well.

http://www.vertigrated.com/blog/2010/04/generic-ad-hoc-queries-in-couchdb/

-- 
Jarrod Roberson

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message