🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

fastify-knex-plugin

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-knex-plugin

Fastify KnexJS Plugin

1.0.3
latest
Source
npm
Version published
Weekly downloads
4
-20%
Maintainers
1
Weekly downloads
 
Created
Source

Fastify KnexJS Plugin

NPM

Installation

npm install fastify-knex-plugin

or

yarn add fastify-knex-plugin

Usage

const options = {
  client: 'mysql',
  connection: {
    host : '127.0.0.1',
    port : 3306,
    user : 'your_database_user',
    password : 'your_database_password',
    database : 'myapp_test'
  }
}

fastify.register(require('fastify-knex-plugin'), options, (err) =>
  console.error(err)
);

fastify.get('/', (request, reply) => {
  console.log(fastify.knex) // Knex DB instance
})

fastify.get('/getProgrammers', async(request, reply) => {
  // example get
  const programmers = await fastify.knex('users').select('name').where('isProgrammer', true)
  reply.send(programmers)
})

Options

KnexJS DB configuration object:

https://knexjs.org/guide/#configuration-options

Author

Tarik BEYAZATLI

License

Licensed under MIT.

Keywords

Fastify

FAQs

Package last updated on 14 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts