Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Server side Javascript or Stored Procedures with MongoDB

1. To store a function, you can use the db.collection.save() as below


db.system.js.save(
{
_id : "addNum" ,
value : function (x, y){ return x + y; }
}
);
2. Java scripts
db.loadServerScripts();
3. call javascript
addNum(17, 25);
Note: 1) There is a special system collection named system.js used to store java script function.
2) Stored JavaScript functions can be reuse.

You might also like