Website | Source | Docs | Cloud-hosted

"Fake Mongo", aka fongo: faked out in-memory mongo for java


Store a JS function on the server: "(NOTE: There are performance limitations to running JavaScript inside of MongoDB.) There is a special system collection named system.js that can store JavaScript functions for reuse. To store a function, you can use the db.collection.save(), as in the following examples:

db.system.js.save(
   {
     _id: "echoFunction",
     value : function(x) { return x; }
   }
)

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

Once you save a function in the system.js collection, you can use the function from any JavaScript context; e.g. $where operator, mapReduce command or db.collection.mapReduce()."


Tags: storage   document   network  

Last modified 27 November 2024