-
-
Save sreeix/955864 to your computer and use it in GitHub Desktop.
What's wrong with this couchdb view?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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