JSPM

knex

0.8.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2056104
  • Score
    100M100P100Q183893F
  • License MIT

A batteries-included SQL query & schema builder for Postgres, MySQL and SQLite3 and the Browser

Package Exports

  • knex
  • knex/build/knex
  • knex/lib/bin/cli.js
  • knex/lib/client
  • knex/lib/dialects/mysql
  • knex/lib/dialects/mysql/index
  • knex/lib/dialects/mysql/index.js
  • knex/lib/dialects/mysql/query/compiler
  • knex/lib/dialects/mysql/schema/columncompiler
  • knex/lib/dialects/mysql/schema/compiler
  • knex/lib/dialects/mysql/schema/tablecompiler
  • knex/lib/dialects/mysql2
  • knex/lib/dialects/oracle
  • knex/lib/dialects/postgres
  • knex/lib/dialects/postgres/query/compiler
  • knex/lib/dialects/postgres/schema/tablecompiler.js
  • knex/lib/dialects/sqlite3
  • knex/lib/dialects/sqlite3/index
  • knex/lib/dialects/sqlite3/index.js
  • knex/lib/dialects/sqlite3/query/compiler
  • knex/lib/dialects/sqlite3/schema/columncompiler
  • knex/lib/dialects/sqlite3/schema/compiler
  • knex/lib/dialects/sqlite3/schema/ddl
  • knex/lib/dialects/sqlite3/schema/tablecompiler
  • knex/lib/dialects/websql/index.js
  • knex/lib/formatter
  • knex/lib/functionhelper
  • knex/lib/helpers
  • knex/lib/index
  • knex/lib/interface
  • knex/lib/migrate
  • knex/lib/migrate/index.js
  • knex/lib/promise
  • knex/lib/query/builder
  • knex/lib/query/compiler
  • knex/lib/query/joinclause
  • knex/lib/query/methods
  • knex/lib/query/string
  • knex/lib/raw
  • knex/lib/runner
  • knex/lib/schema/builder
  • knex/lib/schema/columnbuilder
  • knex/lib/schema/columncompiler
  • knex/lib/schema/compiler
  • knex/lib/schema/tablebuilder
  • knex/lib/schema/tablecompiler
  • knex/lib/schema/tablecompiler.js
  • knex/lib/seed
  • knex/lib/seed/index.js
  • knex/lib/transaction
  • knex/lib/transaction.js
  • knex/lib/util/bluebird.js
  • knex/lib/util/make-client
  • knex/lib/util/make-knex
  • knex/lib/util/parse-connection
  • knex/package
  • knex/package.json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (knex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

knex.js Build Status Coverage Status

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

A batteries-included, multi-dialect (MySQL, PostgreSQL, SQLite3, WebSQL, Oracle) 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: http://bookshelfjs.org

Examples

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) {
  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.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) {
  console.log(row);
})

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