{"_id":"@andyrmitchell/drizzle-robust-transaction","_rev":"7-066f6f5190aef32d26358699f98ded4b","name":"@andyrmitchell/drizzle-robust-transaction","dist-tags":{"latest":"0.0.8"},"versions":{"0.0.2":{"name":"@andyrmitchell/drizzle-robust-transaction","version":"0.0.2","author":"","license":"MIT","_id":"@andyrmitchell/drizzle-robust-transaction@0.0.2","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"homepage":"https://github.com/andymitchell/drizzle-robust-transaction#readme","bugs":{"url":"https://github.com/andymitchell/drizzle-robust-transaction/issues"},"dist":{"shasum":"2ccddaa913e5efc536ce76f4057f164655613a59","tarball":"https://registry.npmjs.org/@andyrmitchell/drizzle-robust-transaction/-/drizzle-robust-transaction-0.0.2.tgz","fileCount":5,"integrity":"sha512-f8yfzCa7wWlgFN0JLLLyoeFr+ZNHUO34TRyXevHuoaT77eURRlaId9gmLzIM1AvSRhS5onRb6ICjreex0IWlaQ==","signatures":[{"sig":"MEQCICNebTTibR2wm9foOMXqtZYflrg6b7xNKuVSIlH1y2N8AiADpc9gov19twTrxAhdUS2XNXH/0US/kgFOfIqeK+V3TA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11980},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"bd5f959160389b2089cbab3de102a9ec04fadb39","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"repository":{"url":"git+https://github.com/andymitchell/drizzle-robust-transaction.git","type":"git"},"_npmVersion":"10.7.0","description":"Sequentially run transactions in Postgres and Sqlite","directories":{},"_nodeVersion":"20.15.1","dependencies":{"drizzle-kit":"^0.29.0","drizzle-orm":"^0.36.4","@libsql/client":"^0.14.0","better-sqlite3":"^11.6.0","@andyrmitchell/utils":"^0.7.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","fs-extra":"^11.2.0","typescript":"^5.7.2","@types/jest":"^29.5.12","@types/uuid":"^9.0.8","@types/fs-extra":"^11.0.4","@types/lodash-es":"^4.17.12","@electric-sql/pglite":"^0.2.14","@types/better-sqlite3":"^7.6.12","@andyrmitchell/file-io":"^0.10.12"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-robust-transaction_0.0.2_1733499297283_0.8081089979711897","host":"s3://npm-registry-packages"}},"0.0.3":{"name":"@andyrmitchell/drizzle-robust-transaction","version":"0.0.3","author":"","license":"MIT","_id":"@andyrmitchell/drizzle-robust-transaction@0.0.3","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"homepage":"https://github.com/andymitchell/drizzle-robust-transaction#readme","bugs":{"url":"https://github.com/andymitchell/drizzle-robust-transaction/issues"},"dist":{"shasum":"edf349b911bbd4292969a6610c2372d1712e6069","tarball":"https://registry.npmjs.org/@andyrmitchell/drizzle-robust-transaction/-/drizzle-robust-transaction-0.0.3.tgz","fileCount":5,"integrity":"sha512-jCsDIJPK/hi/BSZ94kbjW8XtV1fF2WOL2+c/8Jv35vo8r9/Hjk8dFwifyLPXkqSC7brsYVOjrEiyQORh7fJdkQ==","signatures":[{"sig":"MEUCIE2o4VOzqawSPl73ifHVGHisuukZTztxH0O6otZK+uuxAiEAuZDkcXHYiMzpZ6O1pyc4Lwe6kPGcqfI06bgZk/w2J9c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11856},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"139c8b226d9d07f0945260bb961cb4ece7ebff10","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"repository":{"url":"git+https://github.com/andymitchell/drizzle-robust-transaction.git","type":"git"},"_npmVersion":"10.7.0","description":"Sequentially run transactions in Postgres and Sqlite","directories":{},"_nodeVersion":"20.15.1","dependencies":{"drizzle-kit":"^0.29.0","drizzle-orm":"^0.36.4","@libsql/client":"^0.14.0","better-sqlite3":"^11.6.0","@andyrmitchell/utils":"^0.7.6"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","fs-extra":"^11.2.0","typescript":"^5.7.2","@types/jest":"^29.5.12","@types/uuid":"^9.0.8","@types/fs-extra":"^11.0.4","@types/lodash-es":"^4.17.12","@electric-sql/pglite":"^0.2.14","@types/better-sqlite3":"^7.6.12","@andyrmitchell/file-io":"^0.10.12"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-robust-transaction_0.0.3_1733507128314_0.8188312292473399","host":"s3://npm-registry-packages"}},"0.0.4":{"name":"@andyrmitchell/drizzle-robust-transaction","version":"0.0.4","author":"","license":"MIT","_id":"@andyrmitchell/drizzle-robust-transaction@0.0.4","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"homepage":"https://github.com/andymitchell/drizzle-robust-transaction#readme","bugs":{"url":"https://github.com/andymitchell/drizzle-robust-transaction/issues"},"dist":{"shasum":"e48ceffb720cdc2c297b4413ea36a8ff4020f00d","tarball":"https://registry.npmjs.org/@andyrmitchell/drizzle-robust-transaction/-/drizzle-robust-transaction-0.0.4.tgz","fileCount":5,"integrity":"sha512-0I4P082Mqj+3gSe0agoW+AeRho60IhddyI1NVmW1/zQRCmj37deggBUNsi++ZfwYTdRJy7M56UbPSvIkDRG5KA==","signatures":[{"sig":"MEQCIG0zDZxONaspmuU3W8jASX772UF+JWtYpTJtkRKq7vKgAiBXS9UDZopWyTaN6Y7pMGSnwxu4Mu4wekTkmZaE2mYkRQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11022},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"91e1c0bd1170a198884c5b28bc56005e3643a36e","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"repository":{"url":"git+https://github.com/andymitchell/drizzle-robust-transaction.git","type":"git"},"_npmVersion":"10.7.0","description":"Sequentially run transactions in Postgres and Sqlite","directories":{},"_nodeVersion":"20.15.1","dependencies":{"drizzle-kit":"^0.29.0","drizzle-orm":"^0.36.4","@libsql/client":"^0.14.0","better-sqlite3":"^11.6.0","@andyrmitchell/utils":"^0.7.6","@andyrmitchell/drizzle-dialect-types":"^0.0.7"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","fs-extra":"^11.2.0","typescript":"^5.7.2","@types/jest":"^29.5.12","@types/uuid":"^9.0.8","@types/fs-extra":"^11.0.4","@types/lodash-es":"^4.17.12","@electric-sql/pglite":"^0.2.14","@types/better-sqlite3":"^7.6.12","@andyrmitchell/file-io":"^0.10.12"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-robust-transaction_0.0.4_1733659004331_0.4789489110492555","host":"s3://npm-registry-packages"}},"0.0.5":{"name":"@andyrmitchell/drizzle-robust-transaction","version":"0.0.5","author":"","license":"MIT","_id":"@andyrmitchell/drizzle-robust-transaction@0.0.5","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"homepage":"https://github.com/andymitchell/drizzle-robust-transaction#readme","bugs":{"url":"https://github.com/andymitchell/drizzle-robust-transaction/issues"},"dist":{"shasum":"83a4276cfcfb4fe1840008574672362fbc47ace2","tarball":"https://registry.npmjs.org/@andyrmitchell/drizzle-robust-transaction/-/drizzle-robust-transaction-0.0.5.tgz","fileCount":5,"integrity":"sha512-gswfNEuG7Z5TLLRmUx2SKLQ+Lvw0PgcUWXayADpiIK/FnukWMryO2Qv3Zl7qepCHCf2MrbJXHYEpTYHfOX2Kgw==","signatures":[{"sig":"MEQCIArH/k1CGCeJLMwn8NOfANKGN5YF2vEin5Sd+a5Uywq3AiAlxwLFNy2+nkGcP05686KvrnsQVDl8GZysvyYsDkXVQQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11022},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"bbbf9c2e030c3f748d892ff2125a3648840b66b8","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"repository":{"url":"git+https://github.com/andymitchell/drizzle-robust-transaction.git","type":"git"},"_npmVersion":"10.7.0","description":"Sequentially run transactions in Postgres and Sqlite","directories":{},"_nodeVersion":"20.15.1","dependencies":{"drizzle-kit":"^0.29.0","drizzle-orm":"^0.36.4","@libsql/client":"^0.14.0","better-sqlite3":"^11.6.0","@andyrmitchell/utils":"^0.8.3","@andyrmitchell/drizzle-dialect-types":"^0.0.7"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^2.1.8","fs-extra":"^11.2.0","typescript":"^5.7.2","@types/jest":"^29.5.12","@types/uuid":"^9.0.8","@types/fs-extra":"^11.0.4","@types/lodash-es":"^4.17.12","@electric-sql/pglite":"^0.2.14","@types/better-sqlite3":"^7.6.12","@andyrmitchell/file-io":"^0.10.12"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-robust-transaction_0.0.5_1736456458998_0.4702793999017474","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"name":"@andyrmitchell/drizzle-robust-transaction","version":"0.0.6","author":"","license":"MIT","_id":"@andyrmitchell/drizzle-robust-transaction@0.0.6","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"homepage":"https://github.com/andymitchell/drizzle-robust-transaction#readme","bugs":{"url":"https://github.com/andymitchell/drizzle-robust-transaction/issues"},"dist":{"shasum":"7c1638550f8dc6f1dd9fc5127e0f9a1c2384cdd1","tarball":"https://registry.npmjs.org/@andyrmitchell/drizzle-robust-transaction/-/drizzle-robust-transaction-0.0.6.tgz","fileCount":5,"integrity":"sha512-htS87JwmH7ihNLLpGdPw7u4Ozlseifr1AB64Js4/GahVwnQKJM5SG/yESeh/Nsf9SsH5qnqxtpe6dLh7T+HF+g==","signatures":[{"sig":"MEUCIDnctfziDtxd9IRk//ZU5Q582EQBWl177577s8c6UrwnAiEAq5p+EfZmhGesBWdQ8G0h2sQFVeZjjQkPCAO/gVbzqHs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11029},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"c5dd425f656ad12256ced466cafbb5cb2354d7b9","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"repository":{"url":"git+https://github.com/andymitchell/drizzle-robust-transaction.git","type":"git"},"_npmVersion":"10.7.0","description":"Sequentially run transactions in Postgres and Sqlite","directories":{},"_nodeVersion":"20.15.1","dependencies":{"drizzle-kit":"^0.29.0","drizzle-orm":"^0.36.4","@libsql/client":"^0.14.0","better-sqlite3":"^11.6.0","@andyrmitchell/utils":"^0.11.1","@andyrmitchell/drizzle-dialect-types":"^0.0.8"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^3.0.7","fs-extra":"^11.2.0","typescript":"^5.7.2","@types/jest":"^29.5.12","@types/uuid":"^9.0.8","@types/fs-extra":"^11.0.4","@types/lodash-es":"^4.17.12","@electric-sql/pglite":"^0.2.14","@types/better-sqlite3":"^7.6.12","@andyrmitchell/file-io":"^0.10.12"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-robust-transaction_0.0.6_1741193590304_0.14251560698079002","host":"s3://npm-registry-packages-npm-production"}},"0.0.7":{"name":"@andyrmitchell/drizzle-robust-transaction","version":"0.0.7","author":"","license":"MIT","_id":"@andyrmitchell/drizzle-robust-transaction@0.0.7","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"homepage":"https://github.com/andymitchell/drizzle-robust-transaction#readme","bugs":{"url":"https://github.com/andymitchell/drizzle-robust-transaction/issues"},"dist":{"shasum":"8383aeb7be7104dba326f8881b26490294da1d23","tarball":"https://registry.npmjs.org/@andyrmitchell/drizzle-robust-transaction/-/drizzle-robust-transaction-0.0.7.tgz","fileCount":5,"integrity":"sha512-u/i6VwuPmTAWn6AZrYnnIu1wdaz3o9zaN9b7VQmSLsb7bVcTdHBqY2rXgFjLb3OaqpW7ANSPAGkptz1oSSsNGA==","signatures":[{"sig":"MEUCIQC9hu/4kt4kL+ILwk3dkpnNiqU8ETzcyg4QTS8TZ3sEhQIgLrNEzjVJXP33QtAK8k5lF7l+zVePp/fEBapT5bfYvOI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10963},"type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"c304cf0f02e0fb6687e37963fd196e11306fdee3","scripts":{"test":"vitest","build":"tsup","pkglint":"./build/publint_pipeable.sh","test:watch":"vitest --watch","build_prepare":"npm run build && npm run pkglint","build_release":"npm run build_prepare && np","prepublishOnly":"npm run build_prepare"},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"repository":{"url":"git+https://github.com/andymitchell/drizzle-robust-transaction.git","type":"git"},"_npmVersion":"10.7.0","description":"Sequentially run transactions in Postgres and Sqlite","directories":{},"_nodeVersion":"20.15.1","dependencies":{"drizzle-orm":"^0.36.4","@libsql/client":"^0.14.0","better-sqlite3":"^11.6.0","@andyrmitchell/utils":"^0.12.0","@andyrmitchell/drizzle-dialect-types":"^0.0.8"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","vitest":"^3.0.7","fs-extra":"^11.2.0","typescript":"^5.7.2","@types/jest":"^29.5.12","@types/uuid":"^9.0.8","@types/fs-extra":"^11.0.4","@electric-sql/pglite":"^0.2.14","@types/better-sqlite3":"^7.6.12","@andyrmitchell/file-io":"^0.10.12"},"_npmOperationalInternal":{"tmp":"tmp/drizzle-robust-transaction_0.0.7_1741205790488_0.9532533090378723","host":"s3://npm-registry-packages-npm-production"}},"0.0.8":{"name":"@andyrmitchell/drizzle-robust-transaction","version":"0.0.8","description":"Sequentially run transactions in Postgres and Sqlite","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"module":"./dist/index.js","types":"./dist/index.d.ts","publishConfig":{"access":"public"},"scripts":{"build_release":"npm run build_prepare && np","build":"tsup","pkglint":"./build/publint_pipeable.sh","build_prepare":"npm run build && npm run pkglint","prepublishOnly":"npm run build_prepare","test":"vitest","test:watch":"vitest --watch"},"repository":{"type":"git","url":"git+https://github.com/andymitchell/drizzle-robust-transaction.git"},"author":"","license":"MIT","dependencies":{"@andyrmitchell/drizzle-dialect-types":"^0.0.9","@andyrmitchell/utils":"^0.23.1","@libsql/client":"^0.14.0","better-sqlite3":"^11.6.0","drizzle-orm":"^0.36.4"},"devDependencies":{"@andyrmitchell/file-io":"^0.10.12","@electric-sql/pglite":"^0.2.14","@types/better-sqlite3":"^7.6.12","@types/fs-extra":"^11.0.4","@types/jest":"^29.5.12","@types/uuid":"^9.0.8","fs-extra":"^11.2.0","tsup":"^8.3.5","typescript":"^5.7.2","vitest":"^3.0.7"},"_id":"@andyrmitchell/drizzle-robust-transaction@0.0.8","gitHead":"732cb15279ea18f7e42959661381e27080953476","bugs":{"url":"https://github.com/andymitchell/drizzle-robust-transaction/issues"},"homepage":"https://github.com/andymitchell/drizzle-robust-transaction#readme","_nodeVersion":"22.16.0","_npmVersion":"11.5.2","dist":{"integrity":"sha512-nh1KWSk9xp84L55bec/vLeeTQ25yKs4FFkUsp47ubgOMA5Av5PtSH84vOAOVbnTg93B5XZ/hSkBPDgdeZX2zKw==","shasum":"3642e997908c910a6d4f9fbb29fdbee522aeae49","tarball":"https://registry.npmjs.org/@andyrmitchell/drizzle-robust-transaction/-/drizzle-robust-transaction-0.0.8.tgz","fileCount":5,"unpackedSize":10963,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHsbFhFZx//nY+XyLCgAaKM2BsbcsHo8zUKuIMRHsbxpAiBXXAA1E216QK/jdCAoqYJrzX09IPg9+w93OFEoLH2UKg=="}]},"_npmUser":{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"},"directories":{},"maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/drizzle-robust-transaction_0.0.8_1759325678286_0.018885225647252257"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-06T15:34:57.157Z","modified":"2025-10-01T13:34:38.695Z","0.0.2":"2024-12-06T15:34:57.451Z","0.0.3":"2024-12-06T17:45:28.510Z","0.0.4":"2024-12-08T11:56:44.506Z","0.0.5":"2025-01-09T21:00:59.174Z","0.0.6":"2025-03-05T16:53:10.526Z","0.0.7":"2025-03-05T20:16:30.671Z","0.0.8":"2025-10-01T13:34:38.486Z"},"bugs":{"url":"https://github.com/andymitchell/drizzle-robust-transaction/issues"},"license":"MIT","homepage":"https://github.com/andymitchell/drizzle-robust-transaction#readme","repository":{"type":"git","url":"git+https://github.com/andymitchell/drizzle-robust-transaction.git"},"description":"Sequentially run transactions in Postgres and Sqlite","maintainers":[{"name":"andyrmitchell","email":"a.r.mitchell@gmail.com"}],"readme":"Drizzle transactions that will always run sequentially. Compatible with Postgres and Sqlite. \n\nIt essentially makes Sqlite transactions behave the same way as Postgres transactions, which currently* Drizzle does not (*as of drizzle-orm 0.36.4).\n\n# The problem\n\nSqlite's transaction handling is a bag of snakes. \n\nSpecifically:\n- Cannot trust db.transaction when backed by BetterSqlite3: it will interleave concurrent transaction's writes\n- Cannot make LibSQL's driver honour any form of retry with busy_timeout: it will always throw \"database is locked\" immediately and give up\n- Cannot make BetterSqlite3's driver honour attempting to run two concurrent manual (BEGIN) transactions, it will throw \"cannot start a transaction within a transaction\"\n- Cannot use async code in BetterSqlite3's '.transaction' function (it halts immediately)\n\nEssentially Sqlite is not designed for concurrency. It just locks the file, and leaves you to figure out. And the drivers aren't consistent. Annoyingly, Drizzle doesn't seem to be papering over the cracks (yet) - but presumably they will in the future.\n\nLook under the `sql-research` directory and you'll see each of these points confirmed. \n\n# How it works \n\nFor Postgres, it just uses Drizzle's transactions as normal. \n\nFor Sqlite, it will run a custom transaction manually: \n- It issues a BEGIN, and then COMMIT/ROLLBACK depending on whether it succeeds\n- If the BEGIN is blocked by a known concurrency error (e.g. \"database is locked\" or \"cannot start a transaction within a transaction\"), it will retry with jittery exponential back off \n\nIt also attempts to initially use a global memory queue to run transactions sequentially. Which means you only need the jittery exponential back off if concurrent transactions are also coming from a different memory space. This means in most cases, it should execute the transactions in the correct order (and always the correct order for the code within a given memory space). \n\nNote: you may recognise this as an implementation of the \"busy_timeout\" switch (see https://www.sqlite.org/c3ref/busy_timeout.html)\n\n# Usage\n\nIt's a drop in replacement for `db.transaction`. \n\n## For Postgres \n```typescript\nimport { drizzle as drizzlePg } from \"drizzle-orm/pglite\";\nimport { PGlite } from \"@electric-sql/pglite\";\n\nconst client = new PGlite();\nconst db = drizzlePg(client);\n\n// Replaces db.transaction(async (tx) => { /* ... */ })\nrobustTransaction('pg', db, (tx) => {/* ... */})\n\n```\n\n## For Sqlite\n\n```typescript\nimport { drizzle as drizzleBetterSqlite} from 'drizzle-orm/better-sqlite3';\nimport Database from \"better-sqlite3\";\n\nconst url = `local.db`\nconst client = new Database(url);\n\n// Replaces db.transaction(async (tx) => { /* ... */ })\nrobustTransaction('sqlite', db, (tx) => {/* ... */})\n\n```\n\n# The expectation is Drizzle will resolve this, and make it irrelevant\n\nThe tests under the `sql-research` directory are to set to fail if any of the above problems get fixed. \n\nIn time you can either switch back to db.transactions, or update robustTransaction to rely on the parts that work.\n\n# Is there a non-Drizzle version available? \n\nNot directly... Drizzle makes it too easy to handle multiple different drivers. \n\nBut the logic in robustTransaction can easily be run with any specific driver. \n- Copy the robustTransaction function\n- Replace every `db.run(sql.raw(/* sql, e.g. BEGIN */))` with the driver specific way to execute SQL \n\n# Further Discussion\n\n- https://github.com/drizzle-team/drizzle-orm/issues/2275 \n- https://github.com/tursodatabase/libsql-client-ts/issues/288 \n- https://github.com/WiseLibs/better-sqlite3/blob/HEAD/docs/api.md#transactionfunction---function  ","readmeFilename":"README.MD"}