Created
April 15, 2013 23:57
-
-
Save j0x0j/5392290 to your computer and use it in GitHub Desktop.
Parse JSON string inside mongodb $where function
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
db.collection.find({ | |
$where: function() { | |
var obj = eval("(function(){ return " + this.object + " })()"); | |
if(obj.param) { | |
if(obj.param === "something") { | |
return this | |
} else { | |
return false | |
} | |
} else { | |
return false | |
} | |
} | |
}).forEach(function (e, index, array) { printjson(e) }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment