knex
A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser
Last updated 4 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 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 6+ 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.17.6                                ...           latest (4 days ago)
  • 0.18.0-next1                                ...           next (9 hours ago)
  • 0.16.6-oracle-fix                                ...           oracle-fix (2 months ago)

155 Versions

  • 0.18.0-next1                                ...           9 hours ago
  • 0.17.6                                ...           4 days ago
  • 0.17.5                                ...           9 days ago
  • 0.17.4                                ...           9 days ago
  • 0.17.3                                ...           15 days ago
  • 0.17.2                                ...           17 days ago
  • 0.17.1                                ...           18 days ago
  • 0.17.1-next                                ...           18 days ago
  • 0.17.0                                ...           20 days ago
  • 0.17.0-next6                                ...           22 days ago
  • 0.17.0-next5                                ...           a month ago
  • 0.17.0-next4                                ...           a month ago
  • 0.17.0-next2                                ...           a month ago
  • 0.17.0-next                                ...           a month ago
  • 0.16.6-oracle-fix                                ...           2 months ago
  • 0.16.5                                ...           2 months ago
  • 0.16.4                                ...           2 months ago
  • 0.16.4-next2                                ...           3 months ago
  • 0.16.4-next1                                ...           5 months ago
  • 0.16.3                                ...           6 months ago
  • 0.16.2                                ...           6 months ago
  • 0.16.1                                ...           6 months ago
  • 0.16.1-next2                                ...           6 months ago
  • 0.16.1-next1                                ...           6 months ago
  • 0.16.0-next5                                ...           7 months ago
  • 0.16.0-next4                                ...           7 months ago
  • 0.16.0-next3                                ...           9 months ago
  • 0.16.0-next2                                ...           9 months ago
  • 0.16.0-next1                                ...           9 months ago
  • 0.15.2                                ...           a year ago
  • 0.15.1                                ...           a year ago
  • 0.15.0                                ...           a year ago
  • 0.14.6                                ...           a year ago
  • 0.14.5                                ...           a year ago
  • 0.14.4                                ...           a year ago
  • 0.14.3                                ...           a year 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                                ...           2 years ago
  • 0.12.8                                ...           2 years ago
  • 0.12.7                                ...           2 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                                ...           3 years ago
  • 0.10.0-rc1                                ...           3 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                                ...           4 years ago
  • 0.6.23                                ...           4 years ago
  • 0.7.5                                ...           4 years ago
  • 0.7.4                                ...           4 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                                ...           5 years ago
  • 0.5.12                                ...           5 years ago
  • 0.5.11                                ...           5 years ago
  • 0.5.10                                ...           5 years ago
  • 0.5.9                                ...           5 years ago
  • 0.5.8                                ...           5 years ago
  • 0.5.7                                ...           5 years ago
  • 0.5.6                                ...           5 years ago
  • 0.5.5                                ...           5 years ago
  • 0.5.4                                ...           5 years ago
  • 0.5.3                                ...           5 years ago
  • 0.5.2                                ...           5 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 226
This Week 382
This Month 3,701
Last Day 156
Last Week 1,759
Last Month 6,570
Dependencies (17)
Dev Dependencies (41)
Dependents (1313)

Copyright 2014 - 2016 © taobao.org |