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.
You can access that plugin in your handler:
handler: function (request, reply) {
var db = request.server.plugins['hapi-sequelized'].models;
(...)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With