How to load the javascript file stored in machine from the node js

67 views
Skip to first unread message

Soorya Prakash

unread,
Nov 17, 2015, 12:11:01 PM11/17/15
to nodejs, boopathi s, Baskaran R
Hi, 
  I am having the js file stored in the /var/lib/mongodb/sever.js. The server.js file has some predefined functions like below.

db.system.js.save({
    _id: "abs",
    value: function() {
      xxxx;
    }
});

How can I load these file like load("/var/lib/mongodb/server.js") from the node js mongo db driver?

db.eval("function(){ load('/var/lib/mongodb/server.js'); }", function(err, result) {
        console.log("The result of db creation ::::::::::::::::::::::::", result);
        console.log("The error on db creation :::::::::::::::::::::::", err);
        deferred.resolve(true);
    });

I tried the above method but i am getting error as "load not defined". Is there any way to achieve this?

Ken

unread,
Nov 18, 2015, 4:42:40 PM11/18/15
to nodejs, boopathi...@gmail.com, baska...@gmail.com
Not really a node question, but I think you're looking for mongo's loadServerScripts method:

Reply all
Reply to author
Forward
0 new messages