UNPKG

@nestjs-cls/transactional

Version:

A nestjs-cls plugin for transactional decorators

26 lines 991 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTransactionToken = getTransactionToken; exports.InjectTransaction = InjectTransaction; const common_1 = require("@nestjs/common"); const TRANSACTION_TOKEN = Symbol('TRANSACTION_TOKEN'); /** * Get injection token for the Transaction instance. * If name is omitted, the default instance is used. */ function getTransactionToken(connectionName) { return connectionName ? Symbol.for(`${TRANSACTION_TOKEN.description}_${connectionName}`) : TRANSACTION_TOKEN; } /** * Inject the Transaction instance directly (that is the `tx` property of the TransactionHost) * * Optionally, you can provide a connection name to inject a named instance. * * A shorthand for `Inject(getTransactionToken(connectionName))` */ function InjectTransaction(connectionName) { return (0, common_1.Inject)(getTransactionToken(connectionName)); } //# sourceMappingURL=inject-transaction.decorator.js.map