{"name":"knex","version":"3.3.0","description":"A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3","main":"knex.js","types":"types/index.d.ts","engines":{"node":">=16"},"scripts":{"build":"npm run build:ts && npm run format","clean":"node scripts/clean.js","build:ts":"tsc","format":"prettier --write --list-different .","format:check":"prettier --list-different .","debug:test":"mocha --inspect-brk --exit -t 0 test/all-tests-suite.js","debug:tape":"node --inspect-brk test/tape/index.js","lint":"eslint --cache .","lint:fix":"eslint --cache --fix .","prelint:types":"cd test-tstyche && npm i","lint:types":"tsd && tstyche --target 5.4","lint:everything":"npm run lint && npm run lint:types","lint:fix:everything":"npm run lint:fix && npm run lint:types","test:unit":"npm run test:unit-only && npm run test:cli","test:unit-only":"mocha --exit -t 10000 --config test/mocha-unit-config-test.js","test:db":"mocha --exit -t 10000 --config test/mocha-integration-config-test.js","test:db:coverage":"nyc mocha --exit --check-leaks -t 10000 --config test/mocha-integration-config-test.js && npm run test:tape","test:db:no-oracle":"cross-env DB=\"mssql mysql mysql2 mariadb postgres sqlite3\" mocha --exit -t 10000 --config test/mocha-integration-config-test.js && npm run test:tape","test":"mocha --exit -t 10000 --config test/mocha-all-config-test.js && npm run test:tape && npm run test:cli","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:everything":"npm run lint:everything && npm run test:coverage","test:mssql":"cross-env DB=mssql npm run test:db","test:mariadb":"cross-env DB=mariadb npm run test:db","test:mysql":"cross-env DB=mysql npm run test:db","test:mysql2":"cross-env DB=mysql2 npm run test:db","test:oracledb":"cross-env DB=oracledb npm run test:db","test:sqlite":"cross-env DB=sqlite3 npm run test:db","test:better-sqlite3":"cross-env DB=better-sqlite3 npm run test:db","test:postgres":"cross-env DB=postgres npm run test:db","test:cockroachdb":"cross-env DB=cockroachdb npm run test:db","test:pgnative":"cross-env DB=pgnative npm run test:db","test:tape":"node test/tape/index.js | faucet","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","db:start":"docker compose -f scripts/docker-compose.yml up --build -d mysql oracledb postgres mssql mariadb cockroachdb pgnative && docker compose -f scripts/docker-compose.yml up waitmssql waitmysql waitmariadb waitpostgres waitoracledb","db:start:no-oracle":"docker compose -f scripts/docker-compose.yml up --build -d mysql postgres mssql mariadb cockroachdb pgnative && docker compose -f scripts/docker-compose.yml up waitmssql waitmysql waitmariadb waitpostgres","db:stop":"docker compose -f scripts/docker-compose.yml down","db:start:postgres":"docker compose -f scripts/docker-compose.yml up --build -d postgres && docker compose -f scripts/docker-compose.yml up waitpostgres","db:stop:postgres":"docker compose -f scripts/docker-compose.yml down","db:start:pgnative":"docker compose -f scripts/docker-compose.yml up --build -d pgnative && docker compose -f scripts/docker-compose.yml up waitpgnative","db:stop:pgnative":"docker compose -f scripts/docker-compose.yml down","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:mysql":"docker compose -f scripts/docker-compose.yml down","db:start:mariadb":"docker compose -f scripts/docker-compose.yml up --build -d mariadb && docker compose -f scripts/docker-compose.yml up waitmariadb","db:stop:mariadb":"docker compose -f scripts/docker-compose.yml down","db:start:mssql":"docker compose -f scripts/docker-compose.yml up --build -d mssql && docker compose -f scripts/docker-compose.yml up waitmssql","db:stop:mssql":"docker compose -f scripts/docker-compose.yml down","db:start:cockroachdb":"docker compose -f scripts/docker-compose.yml up --build -d cockroachdb && docker compose -f scripts/docker-compose.yml up waitcockroachdb","db:stop:cockroachdb":"docker compose -f scripts/docker-compose.yml down","db:start:oracle":"docker compose -f scripts/docker-compose.yml up --build -d oracledb && docker compose -f scripts/docker-compose.yml up waitoracledb","db:stop:oracle":"docker compose -f scripts/docker-compose.yml down","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 '","stress:destroy":"docker compose -f scripts/stress-test/docker-compose.yml stop"},"dependencies":{"colorette":"2.0.19","commander":"^10.0.0","debug":"4.3.4","escalade":"^3.1.1","esm":"^3.2.25","get-package-type":"^0.1.0","getopts":"2.3.0","interpret":"^2.2.0","lodash":"^4.18.1","pg-connection-string":"2.6.2","rechoir":"^0.8.0","resolve-from":"^5.0.0","tarn":"^3.1.0","tildify":"2.0.0"},"peerDependencies":{"pg-query-stream":"^4.14.0"},"peerDependenciesMeta":{"tedious":{"optional":true},"mariadb":{"optional":true},"mysql":{"optional":true},"mysql2":{"optional":true},"pg":{"optional":true},"pg-native":{"optional":true},"pg-query-stream":{"optional":true},"sqlite3":{"optional":true},"better-sqlite3":{"optional":true}},"lint-staged":{"*":"prettier --ignore-unknown --write","*.js":"eslint --cache --fix"},"devDependencies":{"@tsconfig/node12":"^1.0.11","@tsconfig/recommended":"^1.0.1","@types/minimatch":"^5.1.2","@types/node":"^20.4.0","better-sqlite3":"^10.1.0","chai":"^4.3.6","chai-as-promised":"^7.1.1","chai-subset-in-order":"^3.1.0","cli-testlab":"^3.0.0","cross-env":"^7.0.3","eslint":"^8.54.0","eslint-config-prettier":"^8.6.0","eslint-plugin-import":"^2.29.0","eslint-plugin-mocha-no-only":"^1.1.1","eslint-plugin-n":"^17.23.1","eslint-plugin-prettier":"^4.2.1","expect-type":"^1.3.0","faucet":"^0.0.4","husky":"^8.0.1","jake":"^10.8.5","JSONStream":"^1.3.5","lint-staged":"^16.2.7","mariadb":"^3.5.2","mocha":"^10.0.0","mock-fs":"^5.1.4","mysql":"^2.18.1","mysql2":"^3.2.0","nyc":"^15.1.0","oracledb":"^6.1.0","pg":"^8.20.0","pg-query-stream":"^4.14.0","prettier":"2.8.7","rimraf":"^5.0.5","semver":"^7.7.4","sinon":"^15.0.1","sinon-chai":"^3.7.0","source-map-support":"^0.5.21","sqlite3":"^5.0.11","tape":"^5.6.0","tedious":"^18.2.1","toxiproxy-node-client":"^4.0.0","ts-node":"^10.9.1","tsd":"^0.28.1","tstyche":"^6.2.0","typescript":"5.4.5"},"buildDependencies":["rimraf"],"bin":{"knex":"bin/cli.js"},"repository":{"type":"git","url":"git://github.com/knex/knex.git"},"homepage":"https://knexjs.org/","keywords":["sql","query","postgresql","postgres","mysql","cockroachdb","sqlite3","oracle","mssql","builder","querybuilder","build","db","database"],"author":{"name":"Tim Griesser","url":"https://github.com/tgriesser"},"contributors":[{"name":"Mikael Lepisto"},{"name":"Igor Savin","url":"https://www.codeflashbacks.com"},{"name":"Olivier Cavadenti"},{"name":"Simon Liden"},{"name":"Paul Gaurab","url":"https://lorefnon.tech"},{"name":"Brian Lauber","url":"https://briandamaged.org"}],"browser":{"./lib/migrations/migrate/Migrator.js":"./lib/util/noop.js","./lib/bin/cli.js":"./lib/util/noop.js","./lib/migrations/seed/Seeder.js":"./lib/util/noop.js","tedious":false,"mariadb":false,"mysql":false,"mysql2":false,"pg":false,"pg-native":false,"pg-query-stream":false,"oracle":false,"sqlite3":false,"better-sqlite3":false,"oracledb":false},"react-native":{"./lib/migrate":"./lib/util/noop.js","./lib/seed":"./lib/util/noop.js"},"license":"MIT","tonicExampleFilename":"scripts/runkit-example.js","nyc":{"check-coverage":true,"lines":84,"statements":82,"functions":83,"branches":69,"extension":[".js"],"exclude":["lib/dialects/oracle","lib/dialects/oracledb","test/**/*.spec.js"]},"tsd":{"directory":"test-tsd","compilerOptions":{"esModuleInterop":false,"module":"commonjs","target":"ES2017"}},"_id":"knex@3.3.0","bugs":{"url":"https://github.com/knex/knex/issues"},"_integrity":"sha512-LgWl031hNuLv9Lhxdd9093zULa2aNcoP04Bk29e5NidgRcEr/T0rAr2WYi4BhjTiCDoQiRU56meUE5rppLKZzQ==","_resolved":"/home/runner/work/knex/knex/knex-3.3.0.tgz","_from":"file:knex-3.3.0.tgz","_nodeVersion":"24.17.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-LgWl031hNuLv9Lhxdd9093zULa2aNcoP04Bk29e5NidgRcEr/T0rAr2WYi4BhjTiCDoQiRU56meUE5rppLKZzQ==","shasum":"451d24d5670939fc4ce54f2269163dbf2627d682","tarball":"http://registry-npm.ywwl.com/knex/download/knex-3.3.0.tgz","fileCount":183,"unpackedSize":941393,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/knex@3.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDNfXyDneqVJApaqmTdG4eBf0mrGqPY13nLao9dxmEzRAIhAP4pkuADiCm1oUZz2DGkMqXcaQidKVfq7ptuaLKt4Kqv"}],"size":220501,"noattachment":false,"key":"/knex/-/knex-3.3.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:dfd66eb5-91fc-48b0-bf4a-b25a837e4de1"}},"directories":{},"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"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/knex_3.3.0_1782485803314_0.619434013999081"},"_hasShrinkwrap":false,"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":1782485803597,"_cnpm_publish_time":1782485803597,"dist-tags":{"beta":"0.21.5-next1","latest":"3.3.0","next":"2.5.1","oracle-fix":"0.16.6-oracle-fix"}}