{"name":"knex","version":"3.2.2","keywords":["sql","query","postgresql","postgres","mysql","cockroachdb","sqlite3","oracle","mssql","builder","querybuilder","build","db","database"],"author":{"url":"https://github.com/tgriesser","name":"Tim Griesser"},"license":"MIT","_id":"knex@3.2.2","maintainers":[{"name":"tgriesser","email":"tgriesser10@gmail.com"},{"name":"wubzz","email":"simonliden94@gmail.com"},{"name":"elhigu","email":"mikael.lepisto@vincit.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"olivier.cavadenti","email":"olivier.cavadenti@gmail.com"}],"contributors":[{"name":"Mikael Lepisto"},{"url":"https://www.codeflashbacks.com","name":"Igor Savin"},{"name":"Olivier Cavadenti"},{"name":"Simon Liden"},{"url":"https://lorefnon.tech","name":"Paul Gaurab"},{"url":"https://briandamaged.org","name":"Brian Lauber"}],"homepage":"https://knex.github.io/documentation/","bugs":{"url":"https://github.com/knex/knex/issues"},"bin":{"knex":"bin/cli.js"},"nyc":{"lines":84,"exclude":["lib/dialects/oracle","lib/dialects/oracledb","test/**/*.spec.js"],"branches":69,"extension":[".js"],"functions":83,"statements":82,"check-coverage":true},"tsd":{"directory":"test-tsd","compilerOptions":{"module":"commonjs","target":"ES2017","esModuleInterop":false}},"dist":{"shasum":"175bc1a05863c96aac44bfaa6a9089d923705df9","tarball":"http://registry-npm.ywwl.com/knex/download/knex-3.2.2.tgz","fileCount":198,"integrity":"sha512-BatTKPLkBe8KBYiK08pVUEOc+LVC0gakS5ZCoOUlDmlr5uFISuTqVJu5ZymLSdgtxIPie+hl9MTddktverfqNw==","signatures":[{"sig":"MEUCIQCba/X8IbbKAQHmsGAWyYTB/VfhQKhvx2lAuL8JRSb3gAIgW/AejyOvTtDz0EQGaXyYvvCdER6KkTkK0JripdRkmPA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":983314,"size":229130,"noattachment":false,"key":"/knex/-/knex-3.2.2.tgz"},"main":"knex.js","types":"types/index.d.ts","browser":{"pg":false,"mysql":false,"mysql2":false,"oracle":false,"sqlite3":false,"tedious":false,"oracledb":false,"pg-native":false,"better-sqlite3":false,"pg-query-stream":false,"./lib/bin/cli.js":"./lib/util/noop.js","./lib/migrations/seed/Seeder.js":"./lib/util/noop.js","./lib/migrations/migrate/Migrator.js":"./lib/util/noop.js"},"engines":{"node":">=16"},"exports":{".":{"import":{"types":"./types/index.d.mts","default":"./knex.mjs"},"require":{"types":"./types/index.d.ts","default":"./knex.js"}},"./knex":"./knex.js","./lib/*":["./lib/*","./lib/*.js","./lib/*/index.js"],"./knex.js":"./knex.js","./knex.mjs":"./knex.mjs","./package.json":"./package.json"},"gitHead":"4f56eddad215a0cadf3e42177b3689fbe2dd4790","scripts":{"lint":"eslint --cache .","test":"mocha --exit -t 10000 --config test/mocha-all-config-test.js && npm run test:tape && npm run test:cli","build":"npm run build:ts && npm run format","clean":"node scripts/clean.js","format":"prettier --write --list-different .","db:stop":"docker compose -f scripts/docker-compose.yml down","test:db":"mocha --exit -t 10000 --config test/mocha-integration-config-test.js","build:ts":"tsc","db:start":"docker compose -f scripts/docker-compose.yml up --build -d mysql oracledb postgres mssql cockroachdb pgnative && docker compose -f scripts/docker-compose.yml up waitmssql waitmysql waitpostgres waitoracledb","lint:fix":"eslint --cache --fix .","test:cli":"cross-env KNEX_PATH=../knex.js KNEX=bin/cli.js jake -f test/jake/Jakefile && mocha --exit -t 10000 test/cli-tests-suite.js","coveralls":"nyc report --reporter=lcov","test:tape":"node test/tape/index.js | faucet","test:unit":"npm run test:unit-only && npm run test:cli","debug:tape":"node --inspect-brk test/tape/index.js","debug:test":"mocha --inspect-brk --exit -t 0 test/all-tests-suite.js","lint:types":"tsd","test:mssql":"cross-env DB=mssql npm run test:db","test:mysql":"cross-env DB=mysql npm run test:db","stress:init":"docker compose -f scripts/stress-test/docker-compose.yml up --no-start && docker compose -f scripts/stress-test/docker-compose.yml start","stress:test":"node scripts/stress-test/knex-stress-test.js | grep -A 5 -B 60 -- '- STATS '","test:mysql2":"cross-env DB=mysql2 npm run test:db","test:sqlite":"cross-env DB=sqlite3 npm run test:db","format:check":"prettier --list-different .","db:stop:mssql":"docker compose -f scripts/docker-compose.yml down","db:stop:mysql":"docker compose -f scripts/docker-compose.yml down","test:coverage":"nyc mocha --exit --check-leaks -t 10000 --config test/mocha-all-config-test.js && npm run test:tape && npm run test:cli","test:oracledb":"cross-env DB=oracledb npm run test:db","test:pgnative":"cross-env DB=pgnative npm run test:db","test:postgres":"cross-env DB=postgres npm run test:db","db:start:mssql":"docker compose -f scripts/docker-compose.yml up --build -d mssql && docker compose -f scripts/docker-compose.yml up waitmssql","db:start:mysql":"docker compose -f scripts/docker-compose.yml up --build -d mysql && docker compose -f scripts/docker-compose.yml up waitmysql","db:stop:oracle":"docker compose -f scripts/docker-compose.yml down","stress:destroy":"docker compose -f scripts/stress-test/docker-compose.yml stop","test:unit-only":"mocha --exit -t 10000 --config test/mocha-unit-config-test.js","db:start:oracle":"docker compose -f scripts/docker-compose.yml up --build -d oracledb && docker compose -f scripts/docker-compose.yml up waitoracledb","lint:everything":"npm run lint && npm run lint:types","test:everything":"npm run lint:everything && npm run test:coverage","db:stop:pgnative":"docker compose -f scripts/docker-compose.yml down","db:stop:postgres":"docker compose -f scripts/docker-compose.yml down","test:cockroachdb":"cross-env DB=cockroachdb npm run test:db","test:db:coverage":"nyc mocha --exit --check-leaks -t 10000 --config test/mocha-integration-config-test.js && npm run test:tape","db:start:pgnative":"docker compose -f scripts/docker-compose.yml up --build -d pgnative && docker compose -f scripts/docker-compose.yml up waitpgnative","db:start:postgres":"docker compose -f scripts/docker-compose.yml up --build -d postgres && docker compose -f scripts/docker-compose.yml up waitpostgres","test:db:no-oracle":"cross-env DB=\"mssql mysql mysql2 postgres sqlite3\" mocha --exit -t 10000 --config test/mocha-integration-config-test.js && npm run test:tape","db:start:no-oracle":"docker compose -f scripts/docker-compose.yml up --build -d mysql postgres mssql cockroachdb pgnative && docker compose -f scripts/docker-compose.yml up waitmssql waitmysql waitpostgres","db:stop:cockroachdb":"docker compose -f scripts/docker-compose.yml down","lint:fix:everything":"npm run lint:fix && npm run lint:types","test:better-sqlite3":"cross-env DB=better-sqlite3 npm run test:db","db:start:cockroachdb":"docker compose -f scripts/docker-compose.yml up --build -d cockroachdb && docker compose -f scripts/docker-compose.yml up waitcockroachdb"},"_npmUser":{"name":"kibertoad","email":"iselwin@gmail.com"},"repository":{"url":"git://github.com/knex/knex.git","type":"git"},"_npmVersion":"11.6.2","description":"A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3","directories":{},"lint-staged":{"*":"prettier --ignore-unknown --write","*.js":"eslint --cache --fix"},"_nodeVersion":"24.13.0","dependencies":{"esm":"^3.2.25","tarn":"^3.0.2","debug":"4.3.4","lodash":"^4.17.21","getopts":"2.3.0","rechoir":"^0.8.0","tildify":"2.0.0","escalade":"^3.1.1","colorette":"2.0.19","commander":"^10.0.0","interpret":"^2.2.0","resolve-from":"^5.0.0","get-package-type":"^0.1.0","pg-connection-string":"2.6.2"},"react-native":{"./lib/seed":"./lib/util/noop.js","./lib/migrate":"./lib/util/noop.js"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","nyc":"^15.1.0","tsd":"^0.28.1","chai":"^4.3.6","jake":"^10.8.5","tape":"^5.6.0","husky":"^8.0.1","mocha":"^10.0.0","mysql":"^2.18.1","sinon":"^15.0.1","eslint":"^8.54.0","faucet":"^0.0.4","mysql2":"^3.2.0","rimraf":"^5.0.5","semver":"^7.7.4","mock-fs":"^5.1.4","sqlite3":"^5.0.11","tedious":"^18.2.1","ts-node":"^10.9.1","oracledb":"^6.1.0","prettier":"2.8.7","cross-env":"^7.0.3","JSONStream":"^1.3.5","sinon-chai":"^3.7.0","typescript":"5.0.4","@types/node":"^20.4.0","cli-testlab":"^3.0.0","expect-type":"^1.3.0","lint-staged":"^16.2.7","better-sqlite3":"^10.1.0","eslint-plugin-n":"^17.23.1","pg-query-stream":"^4.14.0","resolve.exports":"^2.0.3","@tsconfig/node12":"^1.0.11","@types/minimatch":"^5.1.2","chai-as-promised":"^7.1.1","source-map-support":"^0.5.21","chai-subset-in-order":"^3.1.0","eslint-plugin-import":"^2.29.0","@tsconfig/recommended":"^1.0.1","toxiproxy-node-client":"^4.0.0","eslint-config-prettier":"^8.6.0","eslint-plugin-prettier":"^4.2.1","eslint-plugin-mocha-no-only":"^1.1.1"},"peerDependencies":{"pg-query-stream":"^4.14.0"},"buildDependencies":["rimraf"],"peerDependenciesMeta":{"pg":{"optional":true},"mysql":{"optional":true},"mysql2":{"optional":true},"sqlite3":{"optional":true},"tedious":{"optional":true},"pg-native":{"optional":true},"better-sqlite3":{"optional":true},"pg-query-stream":{"optional":true}},"tonicExampleFilename":"scripts/runkit-example.js","_npmOperationalInternal":{"tmp":"tmp/knex_3.2.2_1774214878596_0.6420262859592405","host":"s3://npm-registry-packages-npm-production"},"readme":"# [knex.js](https://knexjs.org/)\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[![codecov](https://codecov.io/gh/knex/knex/graph/badge.svg?token=bH39w8lIA9)](https://codecov.io/gh/knex/knex)\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, MariaDB, MySQL, CockroachDB, MSSQL, SQLite3, Oracle (including Oracle Wallet Authentication)) query builder for\nNode.js, featuring:\n\n- [transactions](https://knexjs.org/guide/transactions.html)\n- [connection pooling](https://knexjs.org/guide/#pool)\n- [streaming queries](https://knexjs.org/guide/interfaces.html#streams)\n- both a [promise](https://knexjs.org/#Interfaces-Promises) and [callback](https://knexjs.org/guide/interfaces.html#callbacks) API\n- a [thorough test suite](https://github.com/knex/knex/actions)\n\nNode.js versions 16+ are supported.\n\n- Take a look at the [full documentation](https://knexjs.org/) 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## Local Development Setup\n\n### Prerequisites\n\n- Node.js 16+\n- Python 3.x with `setuptools` installed (required for building native dependencies like `better-sqlite3`)\n\n  Python 3.12+ removed the built-in `distutils` module. If you encounter a `ModuleNotFoundError: No module named 'distutils'` error during `npm install`, install `setuptools` for the Python version used by node-gyp:\n\n  ```bash\n  pip install setuptools\n  ```\n\n- **Windows only:** [Visual Studio Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) with the \"Desktop development with C++\" workload\n\n### Install dependencies\n\n```bash\nnpm install\n```\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  useNullAsDefault: true,\n};\n\nconst knexInstance = knex(config);\n\nknexInstance<User>('users')\n  .select()\n  .then((users) => {\n    console.log(users);\n  })\n  .catch((err) => {\n    console.error(err);\n  })\n  .finally(() => {\n    knexInstance.destroy();\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":1774214878821,"_cnpm_publish_time":1774214878821,"dist-tags":{"beta":"0.21.5-next1","latest":"3.3.0","next":"2.5.1","oracle-fix":"0.16.6-oracle-fix"}}