Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access plugins globally hapijs

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

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

I've tried insterting it to my controllers but it does not seem to recognize the plugin variable.

like image 445
mateeyow Avatar asked Oct 20 '25 04:10

mateeyow


1 Answers

You can access that plugin in your handler:

handler: function (request, reply) {

    var db = request.server.plugins['hapi-sequelized'].models;
    (...)
}
like image 112
Gergo Erdosi Avatar answered Oct 23 '25 22:10

Gergo Erdosi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!