hapi-knex-plugin

1.0.1 • Public • Published

hapi-knex-plugin

Wrap requests with a Knex connection.

Install

NPM

$ npm install hapi-knex-plugin --save

Yarn

$ yarn add hapi-knex-plugin

Usage

In request handlers

In your request handlers you'll have access to request.knex.

server.route({
    method: 'GET',
    path: '/user/{id}',
    handler: function (request, reply) {
        const { id } = request.params;
        request.knex('user')
            .where({ id: id })
            .then(users => reply(users[0]))
            .catch(reply)
    }
});

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i hapi-knex-plugin

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • mglagola