Friday, 17 March 2017

Access mongodb connection variable accessible globally in loopback

How can I access the mongo db connection variable globally in loopback. Currently it is done by executing the async:

Alerts.getDataSource().connector.connect(function (err, db) {
    db.collection("dbname");
    ......................//other code
});

Is it possible make this db variable directly accessible from everywhere inside a model instead than calling connector.connect everywhere? Thanks in advance!



via DevStar

No comments:

Post a Comment