Did you know that you can store javascript functions in mongodb?

Saving Javascript Functions to MongoDB

If you use mongodb you probably have noticed that its really good with javascript.
Did you know that you can actually save javascript functions to the database and run the javascript functions anytime. To save a javascript function run the following command:

db.system.js.save({_id: NAMEOFFUNCTION, value:function(){});

EXAMPLE:

> db.system.js.save({_id:"concatstring",value:function(x){return x+y}});

> db.eval("myAddFunction('OH',' YEA')");
OH YEA






Check out my latest project a career search engine:
http://www.bzcareer.com




Comments

Popular Posts