So, what I’m not sure is that. if in ModuleA, I have:
var mongoose = require('mongoose');
mongoose.connect(pathA);
And in ModuleB, I have:
var mongoose = require('mongoose');
mongoose.connect(pathB);
And in the main program, I have:
var mA = require('./moduleA.js'),
mB = require('./moduleB.js');
So, when I run the main program, I guess I will create two mongoose “instances”; one connecting to pathA and one connecting to pathB, is that right?
Also, in Module B, before I connect to pathB, is it connected to pathA or nothing?
Thanks.
I just did a couple of tests with the latest node V0.4.6. I confirmed the following:
So, what I mean by the above points 1 and 2 is:
If you have a Module Master:
And if you have two other modules:
Module A
Module B
Now when you run a test script that requires both Module A and Module B, instantiate them and output:
You will get the following output:
instead of
Therefore, it is a singleton. not just local to the module.