knex
A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser
Last updated 2 months ago by kibertoad .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install knex 
SYNC missed versions from official npm registry.

knex.js

npm version npm downloads Build Status Coverage Status Dependencies Status Gitter chat Language Grade: JavaScript

A SQL query builder that is flexible, portable, and fun to use!

A batteries-included, multi-dialect (MSSQL, MySQL, PostgreSQL, SQLite3, Oracle (including Oracle Wallet Authentication)) query builder for Node.js, featuring:

Node.js versions 10+ are supported.

Read the full documentation to get started!
Or check out our Recipes wiki to search for solutions to some specific problems
If upgrading from older version, see Upgrading instructions

For support and questions, join the #bookshelf channel on freenode IRC

For an Object Relational Mapper, see:

To see the SQL that Knex will generate for a given query, see: Knex Query Lab

Examples

We have several examples on the website. Here is the first one to get you started:

const knex = require('knex')({
  client: 'sqlite3',
  connection: {
    filename: './data.db',
  },
});

// Create a table
knex.schema
  .createTable('users', table => {
    table.increments('id');
    table.string('user_name');
  })

  // ...and another
  .createTable('accounts', table => {
    table.increments('id');
    table.string('account_name');
    table
      .integer('user_id')
      .unsigned()
      .references('users.id');
  })

  // Then query the table...
  .then(() =>
    knex('users').insert({ user_name: 'Tim' })
  )

  // ...and using the insert id, insert into the other table.
  .then(rows => 
    knex('accounts').insert({ account_name: 'knex', user_id: rows[0] })
  )

  // Query both of the rows.
  .then(() => 
    knex('users')
      .join('accounts', 'users.id', 'accounts.user_id')
      .select('users.user_name as user', 'accounts.account_name as account')
  )

  // .map over the results
  .map(row => {
    console.log(row)
  })

  // Finally, add a .catch handler for the promise chain
  .catch(e => {
    console.error(e);
  });

Current Tags

  • 0.21.1                                ...           latest (2 months ago)
  • 0.18.0-next4                                ...           next (a year ago)
  • 0.16.6-oracle-fix                                ...           oracle-fix (a year ago)

185 Versions

  • 0.21.1                                ...           2 months ago
  • 0.21.0                                ...           2 months ago
  • 0.20.15                                ...           3 months ago
  • 0.20.14                                ...           3 months ago
  • 0.20.13                                ...           3 months ago
  • 0.20.12                                ...           3 months ago
  • 0.20.11                                ...           4 months ago
  • 0.20.10                                ...           4 months ago
  • 0.20.9                                ...           5 months ago
  • 0.20.8                                ...           6 months ago
  • 0.20.7                                ...           6 months ago
  • 0.20.6                                ...           6 months ago
  • 0.20.4                                ...           7 months ago
  • 0.20.3                                ...           7 months ago
  • 0.20.2                                ...           8 months ago
  • 0.20.1                                ...           8 months ago
  • 0.20.0                                ...           8 months ago
  • 0.19.5                                ...           9 months ago
  • 0.19.4                                ...           10 months ago
  • 0.19.3                                ...           10 months ago
  • 0.19.2                                ...           10 months ago
  • 0.19.1                                ...           a year ago
  • 0.19.0                                ...           a year ago
  • 0.18.4                                ...           a year ago
  • 0.18.3                                ...           a year ago
  • 0.18.2                                ...           a year ago
  • 0.18.1                                ...           a year ago
  • 0.18.0                                ...           a year ago
  • 0.18.0-next4                                ...           a year ago
  • 0.18.0-next2                                ...           a year ago
  • 0.18.0-next1                                ...           a year ago
  • 0.17.6                                ...           a year ago
  • 0.17.5                                ...           a year ago
  • 0.17.4                                ...           a year ago
  • 0.17.3                                ...           a year ago
  • 0.17.2                                ...           a year ago
  • 0.17.1                                ...           a year ago
  • 0.17.1-next                                ...           a year ago
  • 0.17.0                                ...           a year ago
  • 0.17.0-next6                                ...           a year ago
  • 0.17.0-next5                                ...           a year ago
  • 0.17.0-next4                                ...           a year ago
  • 0.17.0-next2                                ...           a year ago
  • 0.17.0-next                                ...           a year ago
  • 0.16.6-oracle-fix [deprecated]           ...           a year ago
  • 0.16.5                                ...           a year ago
  • 0.16.4                                ...           a year ago
  • 0.16.4-next2                                ...           a year ago
  • 0.16.4-next1                                ...           a year ago
  • 0.16.3                                ...           2 years ago
  • 0.16.2                                ...           2 years ago
  • 0.16.1                                ...           2 years ago
  • 0.16.1-next2                                ...           2 years ago
  • 0.16.1-next1                                ...           2 years ago
  • 0.16.0-next5                                ...           2 years ago
  • 0.16.0-next4                                ...           2 years ago
  • 0.16.0-next3                                ...           2 years ago
  • 0.16.0-next2                                ...           2 years ago
  • 0.16.0-next1                                ...           2 years ago
  • 0.15.2                                ...           2 years ago
  • 0.15.1                                ...           2 years ago
  • 0.15.0                                ...           2 years ago
  • 0.14.6                                ...           2 years ago
  • 0.14.5                                ...           2 years ago
  • 0.14.4                                ...           2 years ago
  • 0.14.3                                ...           2 years ago
  • 0.14.2                                ...           3 years ago
  • 0.14.1                                ...           3 years ago
  • 0.14.0                                ...           3 years ago
  • 0.13.0                                ...           3 years ago
  • 0.12.9                                ...           3 years ago
  • 0.12.8                                ...           3 years ago
  • 0.12.7                                ...           3 years ago
  • 0.12.6                                ...           4 years ago
  • 0.12.5                                ...           4 years ago
  • 0.12.4 [deprecated]           ...           4 years ago
  • 0.12.3                                ...           4 years ago
  • 0.12.2                                ...           4 years ago
  • 0.12.1                                ...           4 years ago
  • 0.12.0                                ...           4 years ago
  • 0.11.10                                ...           4 years ago
  • 0.11.9                                ...           4 years ago
  • 0.11.8                                ...           4 years ago
  • 0.11.7                                ...           4 years ago
  • 0.11.6                                ...           4 years ago
  • 0.11.5                                ...           4 years ago
  • 0.11.4                                ...           4 years ago
  • 0.11.3                                ...           4 years ago
  • 0.11.2                                ...           4 years ago
  • 0.11.1                                ...           4 years ago
  • 0.11.0                                ...           4 years ago
  • 0.10.0                                ...           4 years ago
  • 0.10.0-rc1                                ...           4 years ago
  • 0.9.0                                ...           5 years ago
  • 0.8.6                                ...           5 years ago
  • 0.8.5                                ...           5 years ago
  • 0.8.4                                ...           5 years ago
  • 0.8.3                                ...           5 years ago
  • 0.8.2                                ...           5 years ago
  • 0.8.1                                ...           5 years ago
  • 0.8.0                                ...           5 years ago
  • 0.7.6                                ...           5 years ago
  • 0.6.23                                ...           5 years ago
  • 0.7.5                                ...           5 years ago
  • 0.7.4                                ...           5 years ago
  • 0.7.3                                ...           6 years ago
  • 0.7.2                                ...           6 years ago
  • 0.7.1                                ...           6 years ago
  • 0.7.0                                ...           6 years ago
  • 0.5.16                                ...           6 years ago
  • 0.6.22                                ...           6 years ago
  • 0.6.21                                ...           6 years ago
  • 0.6.20                                ...           6 years ago
  • 0.6.19                                ...           6 years ago
  • 0.6.18                                ...           6 years ago
  • 0.6.17                                ...           6 years ago
  • 0.6.16                                ...           6 years ago
  • 0.6.15                                ...           6 years ago
  • 0.6.14                                ...           6 years ago
  • 0.6.13                                ...           6 years ago
  • 0.6.12                                ...           6 years ago
  • 0.6.11                                ...           6 years ago
  • 0.6.10                                ...           6 years ago
  • 0.6.9                                ...           6 years ago
  • 0.6.8                                ...           6 years ago
  • 0.6.7                                ...           6 years ago
  • 0.6.6                                ...           6 years ago
  • 0.6.5                                ...           6 years ago
  • 0.6.4                                ...           6 years ago
  • 0.6.3                                ...           6 years ago
  • 0.6.2                                ...           6 years ago
  • 0.6.1                                ...           6 years ago
  • 0.6.0                                ...           6 years ago
  • 0.5.15                                ...           6 years ago
  • 0.5.14                                ...           6 years ago
  • 0.5.13                                ...           6 years ago
  • 0.5.12                                ...           6 years ago
  • 0.5.11                                ...           6 years ago
  • 0.5.10                                ...           6 years ago
  • 0.5.9                                ...           6 years ago
  • 0.5.8                                ...           6 years ago
  • 0.5.7                                ...           6 years ago
  • 0.5.6                                ...           6 years ago
  • 0.5.5                                ...           6 years ago
  • 0.5.4                                ...           6 years ago
  • 0.5.3                                ...           6 years ago
  • 0.5.2                                ...           7 years ago
  • 0.5.1                                ...           7 years ago
  • 0.5.0                                ...           7 years ago
  • 0.4.13                                ...           7 years ago
  • 0.4.12                                ...           7 years ago
  • 0.4.11                                ...           7 years ago
  • 0.4.10                                ...           7 years ago
  • 0.4.9                                ...           7 years ago
  • 0.4.8                                ...           7 years ago
  • 0.4.7                                ...           7 years ago
  • 0.4.6                                ...           7 years ago
  • 0.4.5                                ...           7 years ago
  • 0.4.4                                ...           7 years ago
  • 0.4.3                                ...           7 years ago
  • 0.2.7-alpha                                ...           7 years ago
  • 0.4.2                                ...           7 years ago
  • 0.4.1                                ...           7 years ago
  • 0.4.0                                ...           7 years ago
  • 0.2.6                                ...           7 years ago
  • 0.2.5                                ...           7 years ago
  • 0.2.4                                ...           7 years ago
  • 0.2.3                                ...           7 years ago
  • 0.2.2                                ...           7 years ago
  • 0.2.1                                ...           7 years ago
  • 0.2.0                                ...           7 years ago
  • 0.1.8                                ...           7 years ago
  • 0.1.7                                ...           7 years ago
  • 0.1.6                                ...           7 years ago
  • 0.1.5                                ...           7 years ago
  • 0.1.4                                ...           7 years ago
  • 0.1.3                                ...           7 years ago
  • 0.1.2                                ...           7 years ago
  • 0.1.1                                ...           7 years ago
  • 0.1.0                                ...           7 years ago
  • 0.0.5                                ...           7 years ago
  • 0.0.3                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
  • 0.0.0                                ...           7 years ago
Downloads
Today 4
This Week 726
This Month 257
Last Day 253
Last Week 1,876
Last Month 8,302
Dependencies (15)
Dev Dependencies (36)
Dependents (1798)

Copyright 2014 - 2016 © taobao.org |