couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxepal <...@git.apache.org>
Subject [GitHub] couchdb pull request: Improved Query Options
Date Fri, 14 Mar 2014 23:34:47 GMT
Github user kxepal commented on a diff in the pull request:

    https://github.com/apache/couchdb/pull/180#discussion_r10631246
  
    --- Diff: src/fauxton/app/addons/documents/views.js ---
    @@ -1090,20 +1117,48 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb,
resizeColum
           this.hasReduce = hasReduce;
           this.render();
         },
    +    getKeys: function(val){
    +      var keys = val.value.replace(/\s/g,"");
    +      
    +      var regKeys = keys.match(/(\[.*?\])/g); 
    +      if (regKeys) {
    +        keys = regKeys;
    +      } else {
    +        keys = keys.split(',');
    +      }
    +
    +      keys = _.map(keys, function (key) { return JSON.parse(key); });
    --- End diff --
    
    Could this be more simple: instead of regex, split and iteration over the array with validation
of every item to be valid JSON, just `JSON.parse(keys)` - if `keys` is a valid JSON array,
all elements inside are also have valid JSON format.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message