bellboy 6.3.0 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,17 @@ var __extends = (this && this.__extends) || (function () {
12
12
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
13
  };
14
14
  })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
15
26
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
27
  if (k2 === undefined) k2 = k;
17
28
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -69,7 +80,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
80
  };
70
81
  Object.defineProperty(exports, "__esModule", { value: true });
71
82
  exports.MssqlDestination = void 0;
72
- var utils_1 = require("../utils");
73
83
  var database_destination_1 = require("./base/database-destination");
74
84
  var MssqlDestination = /** @class */ (function (_super) {
75
85
  __extends(MssqlDestination, _super);
@@ -80,7 +90,7 @@ var MssqlDestination = /** @class */ (function (_super) {
80
90
  }
81
91
  MssqlDestination.prototype.loadBatch = function (data) {
82
92
  return __awaiter(this, void 0, void 0, function () {
83
- var sql, _a, db, query, table, columns, transaction, _i, data_1, x, args, ii;
93
+ var sql, _a, pool, db, query, table, columns, _i, data_1, x, args, ii, transaction, err_1;
84
94
  var _b;
85
95
  return __generator(this, function (_c) {
86
96
  switch (_c.label) {
@@ -96,7 +106,8 @@ var MssqlDestination = /** @class */ (function (_super) {
96
106
  _c.label = 4;
97
107
  case 4:
98
108
  sql = _a;
99
- return [4 /*yield*/, utils_1.getDb(this.connection, 'mssql')];
109
+ pool = new sql.ConnectionPool(__assign({}, this.connection));
110
+ return [4 /*yield*/, pool.connect()];
100
111
  case 5:
101
112
  db = _c.sent();
102
113
  return [4 /*yield*/, db.request().query("SELECT TOP(0) * FROM " + this.table)];
@@ -104,10 +115,6 @@ var MssqlDestination = /** @class */ (function (_super) {
104
115
  query = _c.sent();
105
116
  table = query.recordset.toTable(this.table);
106
117
  columns = table.columns.map(function (x) { return x.name; });
107
- transaction = new sql.Transaction(db);
108
- return [4 /*yield*/, transaction.begin()];
109
- case 7:
110
- _c.sent();
111
118
  for (_i = 0, data_1 = data; _i < data_1.length; _i++) {
112
119
  x = data_1[_i];
113
120
  args = [];
@@ -116,11 +123,31 @@ var MssqlDestination = /** @class */ (function (_super) {
116
123
  }
117
124
  (_b = table.rows).add.apply(_b, args);
118
125
  }
119
- return [4 /*yield*/, transaction.request().bulk(table)];
126
+ transaction = new sql.Transaction(db);
127
+ _c.label = 7;
128
+ case 7:
129
+ _c.trys.push([7, 11, , 14]);
130
+ return [4 /*yield*/, transaction.begin()];
120
131
  case 8:
121
132
  _c.sent();
122
- return [4 /*yield*/, transaction.commit()];
133
+ return [4 /*yield*/, transaction.request().bulk(table)];
123
134
  case 9:
135
+ _c.sent();
136
+ return [4 /*yield*/, transaction.commit()];
137
+ case 10:
138
+ _c.sent();
139
+ return [3 /*break*/, 14];
140
+ case 11:
141
+ err_1 = _c.sent();
142
+ return [4 /*yield*/, transaction.rollback()];
143
+ case 12:
144
+ _c.sent();
145
+ return [4 /*yield*/, pool.close()];
146
+ case 13:
147
+ _c.sent();
148
+ throw err_1;
149
+ case 14: return [4 /*yield*/, pool.close()];
150
+ case 15:
124
151
  _c.sent();
125
152
  return [2 /*return*/];
126
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bellboy",
3
- "version": "6.3.0",
3
+ "version": "6.3.1",
4
4
  "description": "Highly performant JavaScript data stream ETL engine.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index",