Created
September 26, 2012 01:08
-
-
Save trisapeace/3785402 to your computer and use it in GitHub Desktop.
eval() problem workaround
This file contains hidden or 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
| // An object of couch view functions that we use | |
| // Note that spacing is very important. | |
| // Do not reformat these values | |
| var validCouchViews = { | |
| getAllIdsByDate : function(doc) {if (doc.dateModified) {emit(doc.dateModified, doc);}}, | |
| searchByQueryString : function(doc) {if ((doc.datumFields) && (doc.session)) {var obj = {};for (i = 0; i < doc.datumFields.length; i++) {if (doc.datumFields[i].mask) {obj[doc.datumFields[i].label] = doc.datumFields[i].mask;}}if (doc.session.sessionFields) {for (j = 0; j < doc.session.sessionFields.length; j++) {if (doc.session.sessionFields[j].mask) {obj[doc.session.sessionFields[j].label] = doc.session.sessionFields[j].mask;}}}emit(obj, doc._id);}} | |
| }; | |
| for (var view in validCouchViews) { | |
| if (fun.map.toString() == validCouchViews[view].toString()) { | |
| fun.map = validCouchViews[view]; | |
| break; | |
| } | |
| } |
This file contains hidden or 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
| var viewQuery = function(fun, idb, options) { | |
| ... | |
| var emit = function(key, val) { ... }; | |
| ... | |
| // fun.map is a function that calls emit(k, v) | |
| eval('fun.map = ' + fun.map.toString() + ';'); | |
| ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment