couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cy Scott <csc...@gmail.com>
Subject Views and AND/OR-like Functionality
Date Fri, 05 Mar 2010 00:28:07 GMT
Just getting started with CouchDB (loving it btw) and am wrapping my brain
around the views. I've seen mention that CouchDB doesn't really handle
ANDing or ORing a la SQL, but is there some way to emulate it?

Here's an example scenario. Say I have documents for different sweaters in
the form of (with _id, _rev, etc.):

{
  "color": "Red", "size": 4, "price": 8.00

}


My data has sweaters of different colors, sizes and prices. The
problem I'm having is when I want to get data for different
permutations like: ALL blue and red sweaters that are size 5 or ANY
green sweaters under $30. I've tried complex keys [doc.color,
doc.size, doc.price] but don't know if this is the right direction.


My simple map function looks like function(doc) { if(doc)
emit([doc.color, doc.size, doc.price], null); };


| key               | value
|----------------------------
|["Blue",  5, 15]  | null
|["Green", 4, 25]  | null
|["Red", 5, 10] | null


Anyone have any thoughts on how to best implement this type of
scenario? Or links to some info, previous thread that might have
covered this. Appreciate any and all help!

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