Skip to content

Instantly share code, notes, and snippets.

@sreeix
Created May 4, 2011 19:40
Show Gist options
  • Save sreeix/955864 to your computer and use it in GitHub Desktop.
Save sreeix/955864 to your computer and use it in GitHub Desktop.
What's wrong with this couchdb view?
function(doc) {
if(doc.expires && doc.status && (doc.status == 'live' || doc.status == 'active')){
var expiryDate = doc.expires.split(/-/); // date format is dd, mm, yy
var expiresOn = new Date(expiryDate[0], expiryDate[1], expiryDate[2]);
var timeNow = new Date();
log('Now '+ timeNow);
log('Expires '+ expiresOn);
if( timeNow.getTime() >= expiresOn.getTime())
emit(doc.coupon_id, null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment