{"_id":"@code-net/database-context","_rev":"6-847c92d860f51923bfb8b2276d6dfcb4","name":"@code-net/database-context","dist-tags":{"latest":"1.3.0"},"versions":{"1.0.0":{"name":"@code-net/database-context","version":"1.0.0","_id":"@code-net/database-context@1.0.0","maintainers":[{"name":"pasi","email":"bartosz.pasinski@gmail.com"}],"dist":{"shasum":"e164c56e9ec83e1ad85feeff9b188b4ea1919387","tarball":"https://registry.npmjs.org/@code-net/database-context/-/database-context-1.0.0.tgz","fileCount":14,"integrity":"sha512-PBuXw+1HM4HjQd6LcgV9OY3N6uZg29+8iRKoggv146YMExZbPHnELMUXpaDY/lXF5PIi7i6/KdRqMlsd7LHmCw==","signatures":[{"sig":"MEQCIA2ptmRkzZTxoShWQ73ztkXbfSXxf/LhspmOZSSAkq9rAiB4XzkpHlzPOBpBpLRTgJ8VZWHkHi8ZUVqFHK6ChYUAQg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7769},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"590c072b449735fe3cb58eff890b3edbf639f82f","_npmUser":{"name":"pasi","email":"bartosz.pasinski@gmail.com"},"_npmVersion":"10.8.2","description":"This library provides an abstraction over database context and decorator to enlist method calls in a transaction.","directories":{},"_nodeVersion":"20.18.1","dependencies":{"tslib":"^2.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/database-context_1.0.0_1749581609482_0.6336586986257593","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@code-net/database-context","version":"1.1.1","_id":"@code-net/database-context@1.1.1","maintainers":[{"name":"pasi","email":"bartosz.pasinski@gmail.com"}],"dist":{"shasum":"a640c03457e5df9e20c2b5d087927aa964941adb","tarball":"https://registry.npmjs.org/@code-net/database-context/-/database-context-1.1.1.tgz","fileCount":14,"integrity":"sha512-D1ig6dly9XYQOPuyoC8gMOUrx0kJp9dX6QPFx7m+WylMfeRf/y3fFY11FnMRzQ/FXhs2xXgu+hMNxNBHKY+dJg==","signatures":[{"sig":"MEYCIQCGReAl8UsWPWrEEeGkiGXyFSHSnINBzd9V82mQEV7NpwIhALKCHPEokn4loXl4mTiaCmnseNeRHagJNcWl5nkzteh5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7766},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"1fb9f8db8c228bd6ea8e5405fc79f387cb8021fb","_npmUser":{"name":"pasi","email":"bartosz.pasinski@gmail.com"},"_npmVersion":"10.8.2","description":"This library provides an abstraction over database context and decorator to enlist method calls in a transaction.","directories":{},"_nodeVersion":"20.18.1","dependencies":{"tslib":"^2.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/database-context_1.1.1_1749581764423_0.9943779849909982","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@code-net/database-context","version":"1.1.2","author":{"url":"https://dev.pasi.pl","name":"Bartosz Pasinski","email":"bartosz.pasinski@gmail.com"},"_id":"@code-net/database-context@1.1.2","maintainers":[{"name":"pasi","email":"bartosz.pasinski@gmail.com"}],"homepage":"https://github.com/CodeNet-pl/NodeJS#readme","bugs":{"url":"https://github.com/CodeNet-pl/NodeJS/issues"},"dist":{"shasum":"651c28f88abbb863751c4337f691bb2e2f4fe9f5","tarball":"https://registry.npmjs.org/@code-net/database-context/-/database-context-1.1.2.tgz","fileCount":14,"integrity":"sha512-ApSrgv9I9O99uJtLh0pSBRpk+JaG5ybCVe72lIoWvSDvPjDfUcvSFSt4CoEZ6zLKQPQHy1MXzVl45565oVWWgA==","signatures":[{"sig":"MEYCIQCjViYPee3cbuqRcufCodD7CwDzIQ77oaUx3xpCE2JCsgIhAJ+PMH9aDo3XiT/DJTDL6OJsLIB7riQLI/SDc+mURYUu","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7965},"main":"./src/index.js","type":"commonjs","_from":"file:code-net-database-context-1.1.2.tgz","types":"./src/index.d.ts","_npmUser":{"name":"pasi","email":"bartosz.pasinski@gmail.com"},"_resolved":"/tmp/acd3b37d341a38c1d51b8401befe00b5/code-net-database-context-1.1.2.tgz","_integrity":"sha512-ApSrgv9I9O99uJtLh0pSBRpk+JaG5ybCVe72lIoWvSDvPjDfUcvSFSt4CoEZ6zLKQPQHy1MXzVl45565oVWWgA==","repository":{"url":"git+https://github.com/CodeNet-pl/NodeJS.git"},"_npmVersion":"10.8.2","description":"This library provides an abstraction over database context and decorator to enlist method calls in a transaction.","directories":{},"_nodeVersion":"20.18.1","dependencies":{"tslib":"^2.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/database-context_1.1.2_1749888222273_0.7475337408675804","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@code-net/database-context","version":"1.2.0","author":{"url":"https://dev.pasi.pl","name":"Bartosz Pasinski","email":"bartosz.pasinski@gmail.com"},"_id":"@code-net/database-context@1.2.0","maintainers":[{"name":"pasi","email":"bartosz.pasinski@gmail.com"}],"homepage":"https://github.com/CodeNet-pl/NodeJS#readme","bugs":{"url":"https://github.com/CodeNet-pl/NodeJS/issues"},"dist":{"shasum":"397992016640673c3437b1072c3cb00d50201116","tarball":"https://registry.npmjs.org/@code-net/database-context/-/database-context-1.2.0.tgz","fileCount":14,"integrity":"sha512-7aP8ezt+uv+F7mIA/3dJ5MHb04qgkMRce4GG9zkgBqzFIHyL/5ewD0EfnGjALAHT4Lb19ZGg1+WDcZNSaORKSg==","signatures":[{"sig":"MEUCIQCoxGW64JyZGGHP5er0TsL1Qc2KutfIFnFBppYW6K3IxgIgfzLnLUSxG82l7JfsYOpQfj6lv0462GqnmvNn/z8ZL7c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7967},"main":"./src/index.js","type":"commonjs","_from":"file:code-net-database-context-1.2.0.tgz","types":"./src/index.d.ts","_npmUser":{"name":"pasi","actor":{"name":"pasi","type":"user","email":"bartosz.pasinski@gmail.com"},"email":"bartosz.pasinski@gmail.com"},"_resolved":"/tmp/c7e77b027129dafd4d8cbb59f2849c03/code-net-database-context-1.2.0.tgz","_integrity":"sha512-7aP8ezt+uv+F7mIA/3dJ5MHb04qgkMRce4GG9zkgBqzFIHyL/5ewD0EfnGjALAHT4Lb19ZGg1+WDcZNSaORKSg==","repository":{"url":"git+https://github.com/CodeNet-pl/NodeJS.git"},"_npmVersion":"10.8.2","description":"This library provides an abstraction over database context and decorator to enlist method calls in a transaction.","directories":{},"_nodeVersion":"20.18.1","dependencies":{"tslib":"^2.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/database-context_1.2.0_1750679288214_0.3607933806816117","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@code-net/database-context","version":"1.3.0","type":"commonjs","main":"./src/index.js","types":"./src/index.d.ts","author":{"name":"Bartosz Pasinski","email":"bartosz.pasinski@gmail.com","url":"https://dev.pasi.pl"},"repository":{"url":"git+https://github.com/CodeNet-pl/NodeJS.git"},"dependencies":{"tslib":"^2.3.0"},"_id":"@code-net/database-context@1.3.0","description":"This library provides an abstraction over database context and decorator to enlist method calls in a transaction.","bugs":{"url":"https://github.com/CodeNet-pl/NodeJS/issues"},"homepage":"https://github.com/CodeNet-pl/NodeJS#readme","_integrity":"sha512-ZGzqKOyK55jVcCU3Oz0we++MmPUB8YXr0x7s7GIZqQXai3tm0HX8Wm6rNC8ZUjt+1wXMbWA9pMUleCBuwHLfcA==","_resolved":"/tmp/15e50737b9608fd30237d15245716ed7/code-net-database-context-1.3.0.tgz","_from":"file:code-net-database-context-1.3.0.tgz","_nodeVersion":"20.19.4","_npmVersion":"10.8.2","dist":{"integrity":"sha512-ZGzqKOyK55jVcCU3Oz0we++MmPUB8YXr0x7s7GIZqQXai3tm0HX8Wm6rNC8ZUjt+1wXMbWA9pMUleCBuwHLfcA==","shasum":"b8b6cd582ef0ac00179a9fe1312e58572a8ce050","tarball":"https://registry.npmjs.org/@code-net/database-context/-/database-context-1.3.0.tgz","fileCount":15,"unpackedSize":9275,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCaEvbIL0W5PYmqcjeqQzyW45Zn64lwdwB9FZkor4wsiQIhAJpTeEH4QadxCE/3oOEKOKMXO3zfkfamb7LXYL+dsRIZ"}]},"_npmUser":{"name":"pasi","email":"bartosz.pasinski@gmail.com"},"directories":{},"maintainers":[{"name":"pasi","email":"bartosz.pasinski@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/database-context_1.3.0_1765562674622_0.4911388994159265"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-10T18:53:29.388Z","modified":"2025-12-12T18:04:34.967Z","1.0.0":"2025-06-10T18:53:29.684Z","1.1.1":"2025-06-10T18:56:04.582Z","1.1.2":"2025-06-14T08:03:42.437Z","1.2.0":"2025-06-23T11:48:08.405Z","1.3.0":"2025-12-12T18:04:34.769Z"},"bugs":{"url":"https://github.com/CodeNet-pl/NodeJS/issues"},"author":{"name":"Bartosz Pasinski","email":"bartosz.pasinski@gmail.com","url":"https://dev.pasi.pl"},"homepage":"https://github.com/CodeNet-pl/NodeJS#readme","repository":{"url":"git+https://github.com/CodeNet-pl/NodeJS.git"},"description":"This library provides an abstraction over database context and decorator to enlist method calls in a transaction.","maintainers":[{"name":"pasi","email":"bartosz.pasinski@gmail.com"}],"readme":"# database-context\n\nThis library provides an abstraction over database context and decorator to enlist method calls in a transaction.\n\n## Usage\n\nTo show an example lets use an in-memory implementation which comes with this package.\n\n```typescript\nimport { InMemoryDatabaseContext, Transactional } from '@code-net/database-context';\n\n\nclass MyService {\n  constructor(private dbContext: DatabaseContext, private otherService: OtherService) {}\n\n  @Transactional()\n  async someMethod() {\n    await this.otherService.otherMethod();\n  }\n}\n\nclass OtherService {\n  @Transactional()\n  async otherMethod() {\n    // some logic\n  }\n}\n\nconst dbContext = new InMemoryDatabaseContext();\nconst myService = new MyService(dbContext, new OtherService());\n\nawait myService.someMethod(); // This will execute in a transaction\n// Note that the OtherService's otherMethod will also be executed in the same transaction\n```\n\n**Important**: The decorator expects that the class has exactly one DatabaseContext instance property.\n\nYou can skip enlisting in the same transaction by passing options argument to the `Transactional` decorator:\n\n```typescript\nclass MyService {\n  @Transactional({\n    independent: true, // This method will not be part of any transaction\n    isolationLevel: 'read committed', // Optional isolation level\n  })\n  async someMethod() {\n    // some logic\n  }\n}\n```\n\nIt is also possible to manually start the transaction.\n\n```typescript\nimport { DatabaseContext } from '@code-net/database-context';\n\nconst dbContext: DatabaseContext();\n\nconst result = await dbContext.transaction(async () => {\n  // Your transactional logic here\n  return 'result';\n}, {\n  independent: false, // This transaction should run in a separate transaction\n  isolationLevel: 'read committed', // Optional isolation level\n});\n```\n\nImplementations of `DatabaseContext` should use async hooks to manage the transaction state.\n","readmeFilename":"README.md"}