My docs look something like this:
{
"_id": "52e131783eb7a3.66772120",
"_rev": "3-a734cbeb70ed87d5e84cd04c269149da",
"billing": {
"plan": "trial",
"trialDays": 14,
"trialEndDate": "2014-02-06 15:14:37",
"nextDate": "",
"stripeId": "",
"cardId": "",
"last4": "",
"outstandingInvoice": "",
"nextAmount": 0
},
"insightly": {
"id": 50111485,
"contactEmailId": 89501608,
"contactPhoneId": 89501609
},
}
So I wrote a view to get all the docs where the trial end date has passed:
"trialEnd": {
"map": "function(doc){var outDoc = {};
var today = new Date();
outDoc.trialEnd =
Date.parse(doc.billing.trialEndDate);
outDoc.insightly = doc.insightly;
outDoc.expiryAge = today - outDoc.trialEnd;
emit(outDoc.expiryAge > 0,outDoc);}"
}
And the parse obviously doesn't do what I think it does. Help anyone? I'm on
bigcouch btw, but local couch 1.2 wouldn't do either.