UNPKG

miter

Version:

A typescript web framework based on ExpressJs based loosely on SailsJs

54 lines 1.93 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); class TransactionImpl { constructor(name, sqlTransact, parentTransaction = null) { this.sqlTransact = sqlTransact; this.parentTransaction = parentTransaction; this._complete = false; this._name = name; this._complete = false; this._transaction = sqlTransact; } get name() { return this._name; } get fullName() { if (!this.parentTransaction) return this.name; else return `${this.parentTransaction.fullName}.${this.name}`; } get isComplete() { return this._complete; } sync() { if (this.isComplete) { throw new Error(`Cannot sync a transaction that has completed!`); } return this._transaction; } rollback() { return __awaiter(this, void 0, void 0, function* () { let t = this.sync(); this._complete = true; yield t.rollback(); }); } commit() { return __awaiter(this, void 0, void 0, function* () { let t = this.sync(); this._complete = true; yield t.commit(); }); } } exports.TransactionImpl = TransactionImpl; //# sourceMappingURL=transaction-impl.js.map