> On May 31, 2016, at 09:25, Emerson Luiz <[email protected]> wrote:
>
> HI,
>
> I need get some info in my MongoDB and set the results as GLOBAL VARS in
> node.js.
>
> Someone has done this before ?
> Can show how you done this ?
That probably isn't a thing you really want to do. It'd go something like this:
myMongoConnection.get('some key', function (err, data) {
if (err) throw new Error("I have no idea how to handle this error because of
what we're doing here");
global.something = data.somethingelse;
})
But what task are you actually trying to do here? If one module is dependent on
another, perhaps have it explicitly depend on it; if this is initialization
step to get configuration that everything else needs, perhaps this belongs in a
loader that makes a config object and passes it to the things that use it. If
it _is_ a config loader, where is the db config coming from?
Knowing what you're trying to do at a higher level might help guide toward a
better design.
Aria
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/6236BA37-33F0-4055-857F-22D7D9F36D6B%40dinhe.net.
For more options, visit https://groups.google.com/d/optout.