allcount / allcountjs

Rapid application development framework for Node.js
http://allcountjs.com
MIT License
402 stars 83 forks source link

Access Crud or mongodb connection instance from custom route #144

Closed justingosan closed 7 years ago

justingosan commented 7 years ago

Is there a way to access the Crud object (ideally) or the mongodb connection instance from an injected custom route?

e.g (from the docs)

injection.bindFactory('myAppConfig', function (app, appAccessRouter, express) {
    return {
        configure: function () {
            appAccessRouter.get('/foo/bar', function (req, res, next) {
                // call Crud or mongodb connection instance here
                res.render('my-view');
            });
        }
    }
});
injection.bindMultiple('appConfigurators', [
    'myAppConfig'
]);

Thanks!

justingosan commented 7 years ago

Figured this out

injection.bindFactory('myAppConfig', function (app, appAccessRouter, express, Crud) {
    return {
        configure: function () {
            appAccessRouter.get('/foo/bar', function (req, res, next) {
                // Crud operations here
                res.render('my-view');
            });
        }
    }
});