couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Alfke <j...@couchbase.com>
Subject Re: Summary view for Pie Charting
Date Thu, 20 Sep 2012 00:18:39 GMT
This isn’t a valid map function, because it’s not purely functional — it uses external
input in the form of the current date/time. So if the map function is run twice on the same
document, it will not always emit the same output. That’s not allowed.

In other words, think of what happens if you generate the index now, and then query it 90
days from now. The information in the index probably won’t be valid because everything will
have expired already, right? But CouchDB has no idea the index is time-sensitive, so it’s
going to return you the old data anyway. You just cannot put time-sensitive data into a map
function.

Instead what you should be doing in the map is writing out the expiration times of the documents.
Then at query time you can see how far in the future those are.

—Jens
Mime
View raw message