Stored JS in MongoDB is saved in the special system.js collection. The documents there should be structured like: {_id: "sum", value: function (x, y) { return x + y; }} _id is the name of the function, and value is the JS code defining the function. Here’s an example of saving such a function and then using it in an eval. This can be run using the MongoDB shell: > db.system.js.save({_id: "sum", ..