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


npm version Build Status Coverage Status Dependencies Status Gitter chat

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), WebSQL) query builder for Node.js and the Browser, featuring:

Read the full documentation to get started!

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


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

var knex = require('knex')({
  dialect: 'sqlite3',
  connection: {
    filename: './data.db'

// Create a table
knex.schema.createTable('users', function(table) {

// ...and another
.createTable('accounts', function(table) {

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

// ...and using the insert id, insert into the other table.
.then(function(rows) {
  return knex.table('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) {

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

Current Tags

  • 0.14.1                                ...           latest (3 years ago)

1 Versions

  • 0.14.1                                ...           3 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (18)
Dev Dependencies (31)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |