I\'ve been trying to figure out how to create a CouchDB view that will let me query all the documents that have a start date greater than A and an end date less than B.
Use an array key in your map function
function (doc) {
var key = [doc.start, doc.end]
emit(key, doc)
}
Then to get documents with a start date greater then 1970-01-01T00:00:00Z and an end date before 1971-01-01T00:00:00Z use the query
?startkey=["1970-01-01T00:00:00Z", ""]&endkey=["\ufff0", "1971-01-01T00:00:00Z"]