{"_id":"@deltic/async-pg-knex","_rev":"7-823d05ee9347c35630263b679aeb11c8","name":"@deltic/async-pg-knex","dist-tags":{"latest":"0.1.7"},"versions":{"0.1.0":{"name":"@deltic/async-pg-knex","version":"0.1.0","keywords":["knex","pg","pool","async","postgres","query-builder"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/async-pg-knex@0.1.0","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"f06db0b0b5a0ce9797e9f475a9de6419485c7c83","tarball":"https://registry.npmjs.org/@deltic/async-pg-knex/-/async-pg-knex-0.1.0.tgz","fileCount":19,"integrity":"sha512-tigXJnXtFnx1XM25MsDVfcM8uZWhpx+NrTVlEWIUykG9W8qvw/qqicsYhCZYWQNCHKJlHGXIbxTECqoXalIKsg==","signatures":[{"sig":"MEQCIHbgmMwb9Y9l2Xj+2aTqHKgStUdHnxc8CMvPiyEk8xYmAiBOn3QZ7A7Bsze6wpp2cVK2PPlu7jrtD2b9ngoYppmFjw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54193},"type":"module","_from":"file:deltic-async-pg-knex-0.1.0.tgz","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs","module-sync":"./dist/index.js"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/90e62ee946ae6b0f464e5bd0ed7a7754/deltic-async-pg-knex-0.1.0.tgz","_integrity":"sha512-tigXJnXtFnx1XM25MsDVfcM8uZWhpx+NrTVlEWIUykG9W8qvw/qqicsYhCZYWQNCHKJlHGXIbxTECqoXalIKsg==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/async-pg-knex"},"_npmVersion":"11.6.0","description":"Knex query builder integration with @deltic/async-pg-pool","directories":{},"_nodeVersion":"24.8.0","dependencies":{"knex":"^3.1.0","@deltic/async-pg-pool":"^0.2.0"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.16.3","@types/pg":"^8.15.6"},"peerDependencies":{"pg":"^8.16.3","@deltic/async-pg-pool":"^0.2.0"},"_npmOperationalInternal":{"tmp":"tmp/async-pg-knex_0.1.0_1774450018782_0.5212911831220843","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@deltic/async-pg-knex","version":"0.1.1","keywords":["knex","pg","pool","async","postgres","query-builder"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/async-pg-knex@0.1.1","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"6e1a4d86c35ebc6b100c23f387b0efad62c85f45","tarball":"https://registry.npmjs.org/@deltic/async-pg-knex/-/async-pg-knex-0.1.1.tgz","fileCount":19,"integrity":"sha512-7nwJ9rg2sqcpSM24tqmkr7sNz7REf0xu2PzbFSltk0hIfTjBNXYK5RUjYgx8Buhni39ux5p0NdGuBGrcdCxeYQ==","signatures":[{"sig":"MEUCIFd05F1259AntXOdRRVAaanBapeLAc8OicoEqO0pXi7CAiEAxbHjzB+8pLNjM8NiV7zH0RvEmq30jpjXFfazHs7iZtU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54341},"type":"module","_from":"file:deltic-async-pg-knex-0.1.1.tgz","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/7ad14e3cd783cd90f3af74c5c9275501/deltic-async-pg-knex-0.1.1.tgz","_integrity":"sha512-7nwJ9rg2sqcpSM24tqmkr7sNz7REf0xu2PzbFSltk0hIfTjBNXYK5RUjYgx8Buhni39ux5p0NdGuBGrcdCxeYQ==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/async-pg-knex"},"_npmVersion":"11.6.0","description":"Knex query builder integration with @deltic/async-pg-pool","directories":{},"_nodeVersion":"24.8.0","dependencies":{"knex":"^3.1.0","@deltic/async-pg-pool":"^0.2.1"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.16.3","@types/pg":"^8.15.6"},"peerDependencies":{"pg":"^8.16.3","@deltic/async-pg-pool":"^0.2.1"},"_npmOperationalInternal":{"tmp":"tmp/async-pg-knex_0.1.1_1774454219158_0.7468013050044675","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@deltic/async-pg-knex","version":"0.1.2","keywords":["knex","pg","pool","async","postgres","query-builder"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/async-pg-knex@0.1.2","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"ae50c3244fe758ae8ed1471ed6cbaf71b5d10be4","tarball":"https://registry.npmjs.org/@deltic/async-pg-knex/-/async-pg-knex-0.1.2.tgz","fileCount":19,"integrity":"sha512-m1xWe60njbPtFUvOrzy1TpMAAHRRGzn5I8b+7geLbpY8FSKb2RXD3WXyfT6RXgcR6ON+KxY45MVsC61MF72rdQ==","signatures":[{"sig":"MEUCIQCgVNcEtulhsKzKf3VsXMAmecjQhjfrMx3WP2Y2kmk6GAIgGd5RGPO3orBzKzn4bpTYi57jBagrskByeP/XR9hCqFg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54488},"type":"module","_from":"file:deltic-async-pg-knex-0.1.2.tgz","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/72118570efc339e76e3ebab44b802185/deltic-async-pg-knex-0.1.2.tgz","_integrity":"sha512-m1xWe60njbPtFUvOrzy1TpMAAHRRGzn5I8b+7geLbpY8FSKb2RXD3WXyfT6RXgcR6ON+KxY45MVsC61MF72rdQ==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/async-pg-knex"},"_npmVersion":"11.6.0","description":"Knex query builder integration with @deltic/async-pg-pool","directories":{},"_nodeVersion":"24.8.0","dependencies":{"knex":"^3.1.0","@deltic/async-pg-pool":"^0.2.2"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.16.3","@types/pg":"^8.15.6"},"peerDependencies":{"pg":"^8.16.3","@deltic/async-pg-pool":"^0.2.2"},"_npmOperationalInternal":{"tmp":"tmp/async-pg-knex_0.1.2_1774454586298_0.5632846885688709","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@deltic/async-pg-knex","version":"0.1.3","keywords":["knex","pg","pool","async","postgres","query-builder"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/async-pg-knex@0.1.3","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"11f3cb87184221eae41e7a8a0765723bea9b6c4f","tarball":"https://registry.npmjs.org/@deltic/async-pg-knex/-/async-pg-knex-0.1.3.tgz","fileCount":19,"integrity":"sha512-+Vkr3vu9X3I7r85T8cMUFy2/xpqZJj405p9OXAewaqV/FifUXn00ukEFXUniUJ8P8L8Hw/8h2ophR9f0lMj4kw==","signatures":[{"sig":"MEUCIQCgNHdjDCZRMhDMA3m/yG6UpVWpXgSftKqpnQwyQuu4ogIgBVTyPyX4H9IpyE0gHLn+ENFFkgR5faVIQRnL8OFSOG4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54880},"type":"module","_from":"file:deltic-async-pg-knex-0.1.3.tgz","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/aa08563e3ec88c4a1b1f73aa37a94c9a/deltic-async-pg-knex-0.1.3.tgz","_integrity":"sha512-+Vkr3vu9X3I7r85T8cMUFy2/xpqZJj405p9OXAewaqV/FifUXn00ukEFXUniUJ8P8L8Hw/8h2ophR9f0lMj4kw==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/async-pg-knex"},"_npmVersion":"11.6.0","description":"Knex query builder integration with @deltic/async-pg-pool","directories":{},"_nodeVersion":"24.8.0","dependencies":{"knex":"^3.2.9","@deltic/async-pg-pool":"^0.2.3"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","@types/pg":"^8.20.0"},"peerDependencies":{"pg":"^8.16.3","@deltic/async-pg-pool":"^0.2.3"},"_npmOperationalInternal":{"tmp":"tmp/async-pg-knex_0.1.3_1775730151505_0.21392361210425337","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@deltic/async-pg-knex","version":"0.1.4","keywords":["knex","pg","pool","async","postgres","query-builder"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/async-pg-knex@0.1.4","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"2759cd2e80ee2ed02cd5f1f164f1547e9204e4e3","tarball":"https://registry.npmjs.org/@deltic/async-pg-knex/-/async-pg-knex-0.1.4.tgz","fileCount":19,"integrity":"sha512-hmEAV5NXTNfWQAKZR/bEUJ22RM5wXgvg+xX8rbWCd9A6yPhNKzLr9dtylSqCBmed/ysk20NgwuyCdLw/wYqUxQ==","signatures":[{"sig":"MEQCIFAwkBbPJbaE3jfbEp4Ejw/USmjUZA5c848aLdxtdEk5AiBAaI1PCE/x2HbU3Vy7yKkw1eaRNeU/OAdB8kQMht1qHQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56396},"type":"module","_from":"file:deltic-async-pg-knex-0.1.4.tgz","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/5b7695b9d0668593fbd125154bc207dc/deltic-async-pg-knex-0.1.4.tgz","_integrity":"sha512-hmEAV5NXTNfWQAKZR/bEUJ22RM5wXgvg+xX8rbWCd9A6yPhNKzLr9dtylSqCBmed/ysk20NgwuyCdLw/wYqUxQ==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/async-pg-knex"},"_npmVersion":"11.6.0","description":"Knex query builder integration with @deltic/async-pg-pool","directories":{},"_nodeVersion":"24.8.0","dependencies":{"knex":"^3.2.9","@deltic/async-pg-pool":"^0.2.3"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","@types/pg":"^8.20.0"},"peerDependencies":{"pg":"^8.16.3","@deltic/async-pg-pool":"^0.2.3"},"_npmOperationalInternal":{"tmp":"tmp/async-pg-knex_0.1.4_1775740373717_0.6717835387703246","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@deltic/async-pg-knex","version":"0.1.5","keywords":["knex","pg","pool","async","postgres","query-builder"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/async-pg-knex@0.1.5","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"1c0937580a66ef9156273901a6423d81d48dbd42","tarball":"https://registry.npmjs.org/@deltic/async-pg-knex/-/async-pg-knex-0.1.5.tgz","fileCount":19,"integrity":"sha512-+8cckgNtPQjcFgRxbL4l4c1xvRp/h/75SCHC7S2NFbBEQHMLrFvAwmKcupFPzIZZ/9TOch+zKDSojapfjknWpA==","signatures":[{"sig":"MEYCIQDICvMvbp+1p26HTTw8SamZNA8RSp2ykcBKtMeh9ajsQwIhAICrAQ9YGKxwbfQDcNIYgjNMqbvNTyIkLg9zSpS/voF5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57028},"type":"module","_from":"file:deltic-async-pg-knex-0.1.5.tgz","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/bb6cbb08001f687de238bdd28f4ab5e3/deltic-async-pg-knex-0.1.5.tgz","_integrity":"sha512-+8cckgNtPQjcFgRxbL4l4c1xvRp/h/75SCHC7S2NFbBEQHMLrFvAwmKcupFPzIZZ/9TOch+zKDSojapfjknWpA==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/async-pg-knex"},"_npmVersion":"11.6.0","description":"Knex query builder integration with @deltic/async-pg-pool","directories":{},"_nodeVersion":"24.8.0","dependencies":{"knex":"^3.2.9","@deltic/async-pg-pool":"^0.2.4"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.20.0","@types/pg":"^8.20.0"},"peerDependencies":{"pg":"^8.16.3","@deltic/async-pg-pool":"^0.2.4"},"_npmOperationalInternal":{"tmp":"tmp/async-pg-knex_0.1.5_1777753805186_0.4507165849853798","host":"s3://npm-registry-packages-npm-production"}},"0.1.7":{"name":"@deltic/async-pg-knex","type":"module","version":"0.1.7","description":"Knex query builder integration with @deltic/async-pg-pool","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs","types":"./dist/index.d.mts"}},"keywords":["knex","pg","pool","async","postgres","query-builder"],"author":{"name":"Frank de Jonge","url":"https://frankdejonge.nl"},"license":"ISC","dependencies":{"knex":"^3.2.9","@deltic/async-pg-pool":"^0.2.4"},"peerDependencies":{"pg":"^8.16.3","@deltic/async-pg-pool":"^0.2.4"},"devDependencies":{"@types/pg":"^8.20.0","pg":"^8.20.0"},"repository":{"type":"git","url":"git+https://github.com/deltic-oss/deltic.git","directory":"packages/async-pg-knex"},"scripts":{},"_id":"@deltic/async-pg-knex@0.1.7","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"homepage":"https://github.com/deltic-oss/deltic#readme","_integrity":"sha512-ca7e09lGJBBBUY0gVU/z04dyRWwkj87Qe1diLj4IKv/ktPomSBDsMQaaAP4Dcd2Qg54BxiaF2l4YsFSzS4A5YQ==","_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/e2e36b5d86ea750e9c9f1f91d56ca587/deltic-async-pg-knex-0.1.7.tgz","_from":"file:deltic-async-pg-knex-0.1.7.tgz","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-ca7e09lGJBBBUY0gVU/z04dyRWwkj87Qe1diLj4IKv/ktPomSBDsMQaaAP4Dcd2Qg54BxiaF2l4YsFSzS4A5YQ==","shasum":"a4fb54437266159232ffe3878072369ec5a57679","tarball":"https://registry.npmjs.org/@deltic/async-pg-knex/-/async-pg-knex-0.1.7.tgz","fileCount":19,"unpackedSize":58382,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCmf/8BYsyLs6nZ2y6JmFUAYzzELzqIWddNd4hZccbthwIgX73M9v8GBAR20GhtGO9MCKlMYxfABKlDQ9JjFaQ0SC0="}]},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"directories":{},"maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/async-pg-knex_0.1.7_1777881501524_0.5627142024813283"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-25T14:46:58.635Z","modified":"2026-05-04T07:58:21.778Z","0.1.0":"2026-03-25T14:46:58.912Z","0.1.1":"2026-03-25T15:56:59.304Z","0.1.2":"2026-03-25T16:03:06.447Z","0.1.3":"2026-04-09T10:22:31.648Z","0.1.4":"2026-04-09T13:12:53.864Z","0.1.5":"2026-05-02T20:30:05.364Z","0.1.7":"2026-05-04T07:58:21.665Z"},"bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"author":{"name":"Frank de Jonge","url":"https://frankdejonge.nl"},"license":"ISC","homepage":"https://github.com/deltic-oss/deltic#readme","keywords":["knex","pg","pool","async","postgres","query-builder"],"repository":{"type":"git","url":"git+https://github.com/deltic-oss/deltic.git","directory":"packages/async-pg-knex"},"description":"Knex query builder integration with @deltic/async-pg-pool","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"readme":"# @deltic/async-pg-knex\n\nKnex query builder integration with `@deltic/async-pg-pool`, giving you full control over connection management while keeping Knex's excellent query building API.\n\n## Why?\n\nKnex manages its own internal connection pool, which works fine for simple applications. However, you lose control over important aspects of connection management:\n\n- **Connection lifecycle hooks** - Run setup/teardown queries when connections are claimed or released (e.g., setting `app.tenant_id` for row-level security)\n- **Request-scoped connections** - Reuse a single \"primary\" connection across an HTTP request\n- **Transaction context** - Share transaction state via `AsyncLocalStorage` without passing transaction objects everywhere\n- **Connection pooling strategy** - Fine-tune how connections are kept warm, when they're released, and how they're reset\n\n`@deltic/async-pg-knex` bridges Knex's query builder with `@deltic/async-pg-pool`, letting you use Knex for query building while `AsyncPgPool` handles all connection management:\n\n```typescript\nconst db = new AsyncKnexConnectionProvider(asyncPool);\n\n// Build and execute queries - connections managed by AsyncPgPool\nconst users = await db.connection()\n    .select('*')\n    .from('users')\n    .where('active', true);\n```\n\n## Installation\n\n```bash\nnpm install @deltic/async-pg-knex @deltic/async-pg-pool knex pg\n```\n\n## Quick Start\n\n```typescript\nimport {Pool} from 'pg';\nimport {AsyncPgPool} from '@deltic/async-pg-pool';\nimport {AsyncKnexConnectionProvider} from '@deltic/async-pg-knex';\n\n// Create the connection stack\nconst pgPool = new Pool({connectionString: 'postgresql://...'});\nconst asyncPool = new AsyncPgPool(pgPool);\nconst db = new AsyncKnexConnectionProvider(asyncPool);\n\n// Query with lazy connection\nconst users = await db.connection()\n    .select('*')\n    .from('users')\n    .where('active', true);\n\n// Callable syntax also works\nconst posts = await db.connection()('posts')\n    .select('title', 'content')\n    .where('published', true)\n    .orderBy('created_at', 'desc')\n    .limit(10);\n```\n\n## Usage\n\n### Basic Queries\n\n```typescript\n// SELECT\nconst users = await db.connection()\n    .select('id', 'name', 'email')\n    .from('users')\n    .where('active', true);\n\n// INSERT with returning\nconst [newUser] = await db.connection()\n    .table('users')\n    .insert({name: 'Alice', email: 'alice@example.com'})\n    .returning('*');\n\n// UPDATE\nawait db.connection()\n    .update('users')\n    .where('id', userId)\n    .update({last_login: new Date()});\n\n// DELETE\nawait db.connection()\n    .table('users')\n    .where('id', userId)\n    .delete();\n```\n\n### Raw Queries\n\n```typescript\n// With positional bindings\nconst result = await db.connection()\n    .raw('SELECT * FROM users WHERE email = ?', ['alice@example.com']);\n\n// With named bindings\nconst result = await db.connection()\n    .raw('SELECT * FROM users WHERE age > :minAge', {minAge: 21});\n```\n\n### Transactions\n\nTransactions acquire a dedicated connection for their duration:\n\n```typescript\nconst trx = await db.begin();\n\ntry {\n    await trx('accounts')\n        .where('id', fromAccountId)\n        .decrement('balance', amount);\n    \n    await trx('accounts')\n        .where('id', toAccountId)\n        .increment('balance', amount);\n    \n    await trx('transfers').insert({\n        from_account: fromAccountId,\n        to_account: toAccountId,\n        amount,\n    });\n    \n    await db.commit(trx);\n} catch (error) {\n    await db.rollback(trx);\n    throw error;\n}\n```\n\n#### Using `runInTransaction`\n\nFor simpler transaction handling with automatic commit/rollback:\n\n```typescript\nconst result = await db.runInTransaction(async () => {\n    const [user] = await db.connection()('users')\n        .insert({name: 'Bob'})\n        .returning('*');\n    \n    await db.connection()('audit_log').insert({\n        action: 'user_created',\n        user_id: user.id,\n    });\n    \n    return user;\n});\n```\n\nIf the function throws, the transaction is automatically rolled back.\n\n#### Custom Isolation Levels\n\n```typescript\nconst trx = await db.begin('BEGIN ISOLATION LEVEL SERIALIZABLE');\n// ... your queries\nawait db.commit(trx);\n```\n\n### Inspecting Queries Without Execution\n\nUse `toSQL()` or `toString()` to inspect queries without acquiring a connection:\n\n```typescript\nconst query = db.connection()\n    .select('*')\n    .from('users')\n    .where('id', 1);\n\n// No connection acquired\nconsole.log(query.toSQL());\n// { sql: 'select * from \"users\" where \"id\" = ?', bindings: [1] }\n\nconsole.log(query.toString());\n// select * from \"users\" where \"id\" = 1\n```\n\n### Raw Client Access\n\nWhen you need direct access to the underlying pg client:\n\n```typescript\nconst client = await db.claimClient();\n\ntry {\n    await client.query('LISTEN my_channel');\n    // ... do something with notifications\n} finally {\n    await db.releaseClient(client);\n}\n```\n\n## API Reference\n\n### `AsyncKnexConnectionProvider`\n\n#### Constructor\n\n```typescript\nnew AsyncKnexConnectionProvider(pool: AsyncPgPool, options?: {\n    knexConfig?: Omit<Knex.Config, 'client' | 'connection'>\n})\n```\n\n#### Methods\n\n| Method | Description |\n|--------|-------------|\n| `connection()` | Returns a lazy `Connection` for building queries |\n| `begin(query?)` | Begins a transaction, returns a `Transaction` |\n| `commit(trx)` | Commits a transaction |\n| `rollback(trx, error?)` | Rolls back a transaction |\n| `withTransaction()` | Returns the current transaction (throws if none) |\n| `inTransaction()` | Returns `true` if currently in a transaction |\n| `runInTransaction(fn)` | Runs a function in a transaction with auto commit/rollback |\n| `claimClient()` | Claims a raw pg `Client` from the pool |\n| `releaseClient(client)` | Releases a raw pg `Client` back to the pool |\n| `destroy()` | Destroys the Knex instance |\n\n### `Connection`\n\nA Knex-like query builder that defers connection acquisition. Supports all standard Knex query methods:\n\n- Query starters: `select`, `insert`, `update`, `delete`, `from`, `into`, `table`\n- Aggregates: `count`, `sum`, `avg`, `min`, `max`, `first`, `pluck`\n- Modifiers: `where`, `orWhere`, `whereIn`, `whereNull`, `orderBy`, `limit`, `offset`, `groupBy`, `having`, `join`, `distinct`\n- Raw queries: `raw`\n- Inspection: `toSQL`, `toString`\n\n### `Transaction`\n\nSimilar to `Connection` but bound to a specific database connection for the transaction's duration. Queries execute immediately rather than lazily.\n\n## How It Works\n\nThis package uses JavaScript Proxies to intercept Knex query builder method calls and route them through `AsyncPgPool`:\n\n1. **`connection()`** returns a Proxy that buffers method calls\n2. **Method calls** (`.select()`, `.where()`, etc.) are recorded\n3. **On `await`** (when `.then()` is called):\n   - A connection is acquired from `AsyncPgPool` (respecting transaction context)\n   - Buffered calls are replayed on a real Knex query builder\n   - The query executes using `.connection()` to bind it to the acquired connection\n   - The connection is released back to the pool (unless in a transaction)\n\n**Transactions** work differently - they immediately acquire a connection via `pool.begin()` and all queries on the transaction object are bound to that connection until commit/rollback.\n\n### Integration with AsyncPgPool Features\n\nBecause connections flow through `AsyncPgPool`, you get all its features:\n\n```typescript\nconst asyncPool = new AsyncPgPool(pgPool, {\n    // Run on every connection claim\n    onClaim: client => client.query(`SET app.tenant_id = '${tenantId}'`),\n    // Run on every connection release  \n    onRelease: 'RESET app.tenant_id',\n    // Keep connections warm\n    keepConnections: 2,\n    maxIdleMs: 5000,\n});\n\nconst db = new AsyncKnexConnectionProvider(asyncPool);\n\n// Queries automatically get tenant_id set\nconst users = await db.connection().select('*').from('users');\n```\n\n## License\n\nISC\n","readmeFilename":"README.md"}