couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathieu Castonguay <>
Subject Question about multiple keys with ranges
Date Wed, 08 Feb 2012 19:49:57 GMT
I have a simple document named Order structure with the fields id, name,
userId and timeScheduled.

What I would like to do is create a view where I can find the
document.idfor those who's userId is some value and timeScheduledis
after a given date.

My view:

"by_users_after_time": {
       "map": "function(doc) { if (doc.userId && doc.timeScheduled) {
emit([doc.timeScheduled, doc.userId], doc._id); }}"

If I do
I get every result back. Is there a way to access key[1] to do an if
doc.userId == key[1] or something along those lines and simply emit on the

This would be the SQL equivalent of select id from Order where userId =
"f98ba9a518650a6c15c566fc6f00c157" and timeScheduled >

I did quite a few Google searches but I can't seem to find a good tutorial
on working with multiple keys. It's also possible that my approach is
entirely flawed so any guidance would be appreciated.

Thank you,


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