Functions Implementation and Understanding

Hi @MWD_Wajih_N_A,

See the documentation for Store a JavaScript Function on the Server to see how a function can be stored.

To use these functions in the mongo shell they will have to be loaded via a call to db.loadServerScripts() first.

For example:

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

Note that these server-side JavaScript functions are not the same thing as MongoDB Realm Functions.

1 Like