Accessing plugins globally hapijs

Is there a way to access globally registered plugins? I have read about hapi-sequelize and I want to implement it in my hapi application. Here is the documentation. It says that you can access it globally with code:

var db = plugin.plugins['hapi-sequelized'].models; db.Test.create({ email: 'some@email.com', password: 'alskfjdfoa' });

I tried to execute it for my controllers, but it doesn't seem to recognize the plugin variable.

+3


source to share


1 answer


You can access this plugin in your handler:



handler: function (request, reply) {

    var db = request.server.plugins['hapi-sequelized'].models;
    (...)
}

      

+4


source







All Articles