Skip to content

Instantly share code, notes, and snippets.

@j0x0j
Created April 15, 2013 23:57
Show Gist options
  • Save j0x0j/5392290 to your computer and use it in GitHub Desktop.
Save j0x0j/5392290 to your computer and use it in GitHub Desktop.
Parse JSON string inside mongodb $where function
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