knex
A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser
Last updated 14 days 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 8+ 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')({
  dialect: 'sqlite3',
  connection: {
    filename: './data.db',
  },
});

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

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

  // Then query the table...
  .then(function() {
    return knex('users').insert({ user_name: 'Tim' });
  })

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

  // Query both of the rows.
  .then(function() {
    return 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(function(row) {
    console.log(row);
  })

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

Current Tags

  • 0.19.5                                ...           latest (14 days ago)
  • 0.18.0-next4                                ...           next (4 months ago)
  • 0.16.6-oracle-fix                                ...           oracle-fix (6 months ago)

168 Versions

  • 0.19.5                                ...           14 days ago
  • 0.19.4                                ...           a month ago
  • 0.19.3                                ...           2 months ago
  • 0.19.2                                ...           2 months ago
  • 0.19.1                                ...           3 months ago
  • 0.19.0                                ...           3 months ago
  • 0.18.4                                ...           3 months ago
  • 0.18.3                                ...           4 months ago
  • 0.18.2                                ...           4 months ago
  • 0.18.1                                ...           4 months ago
  • 0.18.0                                ...           4 months ago
  • 0.18.0-next4                                ...           4 months ago
  • 0.18.0-next2                                ...           4 months ago
  • 0.18.0-next1                                ...           4 months ago
  • 0.17.6                                ...           4 months ago
  • 0.17.5                                ...           4 months ago
  • 0.17.4                                ...           4 months ago
  • 0.17.3                                ...           5 months ago
  • 0.17.2                                ...           5 months ago
  • 0.17.1                                ...           5 months ago
  • 0.17.1-next                                ...           5 months ago
  • 0.17.0                                ...           5 months ago
  • 0.17.0-next6                                ...           5 months ago
  • 0.17.0-next5                                ...           5 months ago
  • 0.17.0-next4                                ...           5 months ago
  • 0.17.0-next2                                ...           5 months ago
  • 0.17.0-next                                ...           5 months ago
  • 0.16.6-oracle-fix [deprecated]           ...           6 months ago
  • 0.16.5                                ...           6 months ago
  • 0.16.4                                ...           6 months ago
  • 0.16.4-next2                                ...           7 months ago
  • 0.16.4-next1                                ...           9 months ago
  • 0.16.3                                ...           10 months ago
  • 0.16.2                                ...           10 months ago
  • 0.16.1                                ...           10 months ago
  • 0.16.1-next2                                ...           10 months ago
  • 0.16.1-next1                                ...           a year ago
  • 0.16.0-next5                                ...           a year ago
  • 0.16.0-next4                                ...           a year ago
  • 0.16.0-next3                                ...           a year ago
  • 0.16.0-next2                                ...           a year ago
  • 0.16.0-next1                                ...           a year ago
  • 0.15.2                                ...           a year ago
  • 0.15.1                                ...           a year ago
  • 0.15.0                                ...           a year 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                                ...           2 years ago
  • 0.14.1                                ...           2 years ago
  • 0.14.0                                ...           2 years ago
  • 0.13.0                                ...           2 years ago
  • 0.12.9                                ...           3 years ago
  • 0.12.8                                ...           3 years ago
  • 0.12.7                                ...           3 years ago
  • 0.12.6                                ...           3 years ago
  • 0.12.5                                ...           3 years ago
  • 0.12.4 [deprecated]           ...           3 years ago
  • 0.12.3                                ...           3 years ago
  • 0.12.2                                ...           3 years ago
  • 0.12.1                                ...           3 years ago
  • 0.12.0                                ...           3 years ago
  • 0.11.10                                ...           3 years ago
  • 0.11.9                                ...           3 years ago
  • 0.11.8                                ...           3 years ago
  • 0.11.7                                ...           3 years ago
  • 0.11.6                                ...           3 years ago
  • 0.11.5                                ...           3 years ago
  • 0.11.4                                ...           3 years ago
  • 0.11.3                                ...           3 years ago
  • 0.11.2                                ...           3 years ago
  • 0.11.1                                ...           3 years ago
  • 0.11.0                                ...           3 years ago
  • 0.10.0                                ...           4 years ago
  • 0.10.0-rc1                                ...           4 years ago
  • 0.9.0                                ...           4 years ago
  • 0.8.6                                ...           4 years ago
  • 0.8.5                                ...           4 years ago
  • 0.8.4                                ...           4 years ago
  • 0.8.3                                ...           4 years ago
  • 0.8.2                                ...           4 years ago
  • 0.8.1                                ...           4 years ago
  • 0.8.0                                ...           4 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                                ...           5 years ago
  • 0.7.2                                ...           5 years ago
  • 0.7.1                                ...           5 years ago
  • 0.7.0                                ...           5 years ago
  • 0.5.16                                ...           5 years ago
  • 0.6.22                                ...           5 years ago
  • 0.6.21                                ...           5 years ago
  • 0.6.20                                ...           5 years ago
  • 0.6.19                                ...           5 years ago
  • 0.6.18                                ...           5 years ago
  • 0.6.17                                ...           5 years ago
  • 0.6.16                                ...           5 years ago
  • 0.6.15                                ...           5 years ago
  • 0.6.14                                ...           5 years ago
  • 0.6.13                                ...           5 years ago
  • 0.6.12                                ...           5 years ago
  • 0.6.11                                ...           5 years ago
  • 0.6.10                                ...           5 years ago
  • 0.6.9                                ...           5 years ago
  • 0.6.8                                ...           5 years ago
  • 0.6.7                                ...           5 years ago
  • 0.6.6                                ...           5 years ago
  • 0.6.5                                ...           5 years ago
  • 0.6.4                                ...           5 years ago
  • 0.6.3                                ...           5 years ago
  • 0.6.2                                ...           5 years ago
  • 0.6.1                                ...           5 years ago
  • 0.6.0                                ...           5 years ago
  • 0.5.15                                ...           5 years ago
  • 0.5.14                                ...           5 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                                ...           6 years ago
  • 0.5.1                                ...           6 years ago
  • 0.5.0                                ...           6 years ago
  • 0.4.13                                ...           6 years ago
  • 0.4.12                                ...           6 years ago
  • 0.4.11                                ...           6 years ago
  • 0.4.10                                ...           6 years ago
  • 0.4.9                                ...           6 years ago
  • 0.4.8                                ...           6 years ago
  • 0.4.7                                ...           6 years ago
  • 0.4.6                                ...           6 years ago
  • 0.4.5                                ...           6 years ago
  • 0.4.4                                ...           6 years ago
  • 0.4.3                                ...           6 years ago
  • 0.2.7-alpha                                ...           6 years ago
  • 0.4.2                                ...           6 years ago
  • 0.4.1                                ...           6 years ago
  • 0.4.0                                ...           6 years ago
  • 0.2.6                                ...           6 years ago
  • 0.2.5                                ...           6 years ago
  • 0.2.4                                ...           6 years ago
  • 0.2.3                                ...           6 years ago
  • 0.2.2                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.8                                ...           6 years ago
  • 0.1.7                                ...           6 years ago
  • 0.1.6                                ...           6 years ago
  • 0.1.5                                ...           6 years ago
  • 0.1.4                                ...           6 years ago
  • 0.1.3                                ...           6 years ago
  • 0.1.2                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.5                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
Downloads
Today 32
This Week 1,629
This Month 3,848
Last Day 104
Last Week 2,058
Last Month 7,026
Dependencies (15)
Dev Dependencies (33)
Dependents (1450)

Copyright 2014 - 2017 © taobao.org |