couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John <john.mg.al...@gmail.com>
Subject JSON arrays in CouchDB
Date Sat, 30 Mar 2013 14:44:53 GMT
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"

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message