How does CouchDB handle JSON arrays? I'm trying to create a filter for
selective replication and I've tried everything to try and iterate through
the contents of an json array to check the contents but nothing seems to
work. My code is:
function (doc, rec) {
if (doc.expiryDate == null && doc.countries.indexOf(rec.query.country) !=
-1) {
return doc;
} else {
var expiry = doc.expiryDate;
if (expiry > rec.query.today
&& doc.countries.indexOf(rec.query.country) != -1) {
return doc;
}
}}
And the JSON looks like:
"countries": [
"GB",
"US"],
I've ran out of ideas of how to get this working now, although I'm sure the
problem is "doc.countries"