{"name":"knex","version":"0.2.7-alpha","description":"A query builder for Postgres, MySQL and SQLite3, designed to be flexible, portable, and fun to use.","main":"knex.js","directories":{"test":"test"},"devDependencies":{"mocha":"~1.12.0","objectdump":"~0.3.0","mysql":"~2.0.0-alpha7","pg":"~2.3.1","sqlite3":"~2.1.7","node-uuid":"~1.4.0","grunt":"~0.4.1","grunt-release":"~0.5.1"},"dependencies":{"when":"~2.3.0","underscore":"~1.5.1","generic-pool":"~2.0.3","underscore.string":"~2.3.3","mkdirp":"~0.3.5"},"scripts":{"test":"mocha -R spec test/index.js"},"repository":{"type":"git","url":"https://github.com/tgriesser/knex.git"},"keywords":["sql","query","postgresql","mysql","sqlite3"],"author":{"name":"Tim Griesser","url":"https://github.com/tgriesser"},"license":"MIT","bugs":{"url":"https://github.com/tgriesser/knex/issues"},"_id":"knex@0.2.7-alpha","dist":{"shasum":"294c16672dafc8f180340515f553337d0555e25d","tarball":"http://registry-npm.ywwl.com/knex/download/knex-0.2.7-alpha.tgz","integrity":"sha512-zodh1Yhnn3qeF5Oq/8ia1b9WVC3emtrBOTAEF/CixYUD1XOpgIObb3VLzOg4/1eQhDWO8LLzUBfXIAupq5nnSA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDKpauR0vDJYmJ4/QcXoGi1ChmWAfUlALD/ywceH77LUwIgQ7IbJjPYH0rYW3GsdbO93s3FYUnCbPSmMk4SRhY2tXU="}],"size":36834,"noattachment":false,"key":"/knex/-/knex-0.2.7-alpha.tgz"},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"tgriesser","email":"tgriesser10@gmail.com"},"maintainers":[{"name":"tgriesser","email":"tgriesser10@gmail.com"}],"readme":"# [knex.js](https://knex.github.io/documentation/)\n\n[![npm version](http://img.shields.io/npm/v/knex.svg)](https://npmjs.org/package/knex)\n[![npm downloads](https://img.shields.io/npm/dm/knex.svg)](https://npmjs.org/package/knex)\n![](https://github.com/knex/knex/workflows/CI/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/knex/knex/badge.svg?branch=master)](https://coveralls.io/r/knex/knex?branch=master)\n[![Dependencies Status](https://img.shields.io/librariesio/github/knex/knex)](https://libraries.io/npm/knex)\n[![Gitter chat](https://badges.gitter.im/tgriesser/knex.svg)](https://gitter.im/tgriesser/knex)\n\n> **A SQL query builder that is _flexible_, _portable_, and _fun_ to use!**\n\nA batteries-included, multi-dialect (PostgreSQL, MySQL, CockroachDB, MSSQL, SQLite3, Oracle (including Oracle Wallet Authentication)) query builder for\nNode.js, featuring:\n\n- [transactions](https://knex.github.io/documentation/#Transactions)\n- [connection pooling](https://knex.github.io/documentation/#Installation-pooling)\n- [streaming queries](https://knex.github.io/documentation/#Interfaces-Streams)\n- both a [promise](https://knex.github.io/documentation/#Interfaces-Promises) and [callback](https://knex.github.io/documentation/#Interfaces-Callbacks) API\n- a [thorough test suite](https://github.com/knex/knex/actions)\n\nNode.js versions 12+ are supported.\n\n- Take a look at the [full documentation](https://knex.github.io/documentation) to get started!\n- Browse the [list of plugins and tools](https://github.com/knex/knex/blob/master/ECOSYSTEM.md) built for knex\n- Check out our [recipes wiki](https://github.com/knex/knex/wiki/Recipes) to search for solutions to some specific problems\n- In case of upgrading from an older version, see [migration guide](https://github.com/knex/knex/blob/master/UPGRADING.md)\n\nYou can report bugs and discuss features on the [GitHub issues page](https://github.com/knex/knex/issues) or send tweets to [@kibertoad](http://twitter.com/kibertoad).\n\nFor support and questions, join our [Gitter channel](https://gitter.im/tgriesser/knex).\n\nFor knex-based Object Relational Mapper, see:\n\n- https://github.com/Vincit/objection.js\n- https://github.com/mikro-orm/mikro-orm\n- https://bookshelfjs.org\n\nTo see the SQL that Knex will generate for a given query, you can use [Knex Query Lab](https://michaelavila.com/knex-querylab/)\n\n## Examples\n\nWe have several examples [on the website](http://knexjs.org). Here is the first one to get you started:\n\n```js\nconst knex = require('knex')({\n  client: 'sqlite3',\n  connection: {\n    filename: './data.db',\n  },\n});\n\ntry {\n  // Create a table\n  await knex.schema\n    .createTable('users', (table) => {\n      table.increments('id');\n      table.string('user_name');\n    })\n    // ...and another\n    .createTable('accounts', (table) => {\n      table.increments('id');\n      table.string('account_name');\n      table.integer('user_id').unsigned().references('users.id');\n    });\n\n  // Then query the table...\n  const insertedRows = await knex('users').insert({ user_name: 'Tim' });\n\n  // ...and using the insert id, insert into the other table.\n  await knex('accounts').insert({\n    account_name: 'knex',\n    user_id: insertedRows[0],\n  });\n\n  // Query both of the rows.\n  const selectedRows = await knex('users')\n    .join('accounts', 'users.id', 'accounts.user_id')\n    .select('users.user_name as user', 'accounts.account_name as account');\n\n  // map over the results\n  const enrichedRows = selectedRows.map((row) => ({ ...row, active: true }));\n\n  // Finally, add a catch statement\n} catch (e) {\n  console.error(e);\n}\n```\n\n## TypeScript example\n\n```ts\nimport { Knex, knex } from 'knex';\n\ninterface User {\n  id: number;\n  age: number;\n  name: string;\n  active: boolean;\n  departmentId: number;\n}\n\nconst config: Knex.Config = {\n  client: 'sqlite3',\n  connection: {\n    filename: './data.db',\n  },\n};\n\nconst knexInstance = knex(config);\n\ntry {\n  const users = await knex<User>('users').select('id', 'age');\n} catch (err) {\n  // error handling\n}\n```\n\n## Usage as ESM module\n\nIf you are launching your Node application with `--experimental-modules`, `knex.mjs` should be picked up automatically and named ESM import should work out-of-the-box.\nOtherwise, if you want to use named imports, you'll have to import knex like this:\n\n```js\nimport { knex } from 'knex/knex.mjs';\n```\n\nYou can also just do the default import:\n\n```js\nimport knex from 'knex';\n```\n\nIf you are not using TypeScript and would like the IntelliSense of your IDE to work correctly, it is recommended to set the type explicitly:\n\n```js\n/**\n * @type {Knex}\n */\nconst database = knex({\n  client: 'mysql',\n  connection: {\n    host: '127.0.0.1',\n    user: 'your_database_user',\n    password: 'your_database_password',\n    database: 'myapp_test',\n  },\n});\ndatabase.migrate.latest();\n```\n","publish_time":1379512309879,"_cnpm_publish_time":1379512309879,"dist-tags":{"beta":"0.21.5-next1","latest":"3.3.0","next":"2.5.1","oracle-fix":"0.16.6-oracle-fix"}}