@proteinjs/db 1.6.0 → 1.8.0
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.
- package/CHANGELOG.md +22 -0
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +3 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/src/Db.d.ts +30 -4
- package/dist/src/Db.d.ts.map +1 -1
- package/dist/src/Db.js +66 -75
- package/dist/src/Db.js.map +1 -1
- package/dist/src/Table.d.ts +4 -0
- package/dist/src/Table.d.ts.map +1 -1
- package/dist/src/Table.js +104 -1
- package/dist/src/Table.js.map +1 -1
- package/dist/src/reference/Reference.d.ts +1 -0
- package/dist/src/reference/Reference.d.ts.map +1 -1
- package/dist/src/reference/Reference.js +3 -0
- package/dist/src/reference/Reference.js.map +1 -1
- package/dist/src/services/TransactionRunnerService.d.ts +7 -0
- package/dist/src/services/TransactionRunnerService.d.ts.map +1 -0
- package/dist/src/services/TransactionRunnerService.js +6 -0
- package/dist/src/services/TransactionRunnerService.js.map +1 -0
- package/dist/src/transaction/Transaction.d.ts +69 -0
- package/dist/src/transaction/Transaction.d.ts.map +1 -0
- package/dist/src/transaction/Transaction.js +255 -0
- package/dist/src/transaction/Transaction.js.map +1 -0
- package/dist/src/transaction/TransactionRunner.d.ts +7 -0
- package/dist/src/transaction/TransactionRunner.d.ts.map +1 -0
- package/dist/src/transaction/TransactionRunner.js +88 -0
- package/dist/src/transaction/TransactionRunner.js.map +1 -0
- package/dist/test/TransactionDb.test.d.ts +2 -0
- package/dist/test/TransactionDb.test.d.ts.map +1 -0
- package/dist/test/TransactionDb.test.js +404 -0
- package/dist/test/TransactionDb.test.js.map +1 -0
- package/dist/test/reusable/TransactionTests.d.ts +52 -0
- package/dist/test/reusable/TransactionTests.d.ts.map +1 -0
- package/dist/test/reusable/TransactionTests.js +396 -0
- package/dist/test/reusable/TransactionTests.js.map +1 -0
- package/generated/index.ts +3 -1
- package/index.ts +5 -2
- package/package.json +2 -2
- package/src/Db.ts +63 -28
- package/src/Table.ts +23 -0
- package/src/reference/Reference.ts +4 -0
- package/src/services/TransactionRunnerService.ts +10 -0
- package/src/transaction/Transaction.ts +186 -0
- package/src/transaction/TransactionRunner.ts +18 -0
- package/test/TransactionDb.test.ts +335 -0
- package/test/reusable/TransactionTests.ts +234 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
var moment_1 = __importDefault(require("moment"));
|
|
58
|
+
var Transaction_1 = require("../src/transaction/Transaction");
|
|
59
|
+
var Table_1 = require("../src/Table");
|
|
60
|
+
var Record_1 = require("../src/Record");
|
|
61
|
+
var Columns_1 = require("../src/Columns");
|
|
62
|
+
var EmployeeTestTable = /** @class */ (function (_super) {
|
|
63
|
+
__extends(EmployeeTestTable, _super);
|
|
64
|
+
function EmployeeTestTable() {
|
|
65
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
66
|
+
_this.name = 'db_test_employee';
|
|
67
|
+
_this.columns = (0, Record_1.withRecordColumns)({
|
|
68
|
+
name: new Columns_1.StringColumn('name'),
|
|
69
|
+
department: new Columns_1.StringColumn('department'),
|
|
70
|
+
isRemote: new Columns_1.BooleanColumn('is_remote'),
|
|
71
|
+
jobTitle: new Columns_1.StringColumn('job_title'),
|
|
72
|
+
startDate: new Columns_1.DateColumn('start_date'),
|
|
73
|
+
object: new Columns_1.StringColumn('object'),
|
|
74
|
+
});
|
|
75
|
+
return _this;
|
|
76
|
+
}
|
|
77
|
+
return EmployeeTestTable;
|
|
78
|
+
}(Table_1.Table));
|
|
79
|
+
describe('Transaction db', function () {
|
|
80
|
+
var employeeTable = new EmployeeTestTable();
|
|
81
|
+
var transaction;
|
|
82
|
+
var insertCallback;
|
|
83
|
+
var updateCallback;
|
|
84
|
+
var deleteCallback;
|
|
85
|
+
beforeEach(function () {
|
|
86
|
+
insertCallback = jest.fn();
|
|
87
|
+
updateCallback = jest.fn();
|
|
88
|
+
deleteCallback = jest.fn();
|
|
89
|
+
transaction = new Transaction_1.Transaction(insertCallback, updateCallback, deleteCallback);
|
|
90
|
+
});
|
|
91
|
+
describe('insert', function () {
|
|
92
|
+
it('should add record to cached db and queue insert operation', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
var record, result;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
switch (_a.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
record = {
|
|
98
|
+
name: 'John Doe',
|
|
99
|
+
department: 'Engineering',
|
|
100
|
+
jobTitle: 'Software Engineer',
|
|
101
|
+
isRemote: true,
|
|
102
|
+
startDate: new Date('2024-01-01'),
|
|
103
|
+
};
|
|
104
|
+
return [4 /*yield*/, transaction.insert(employeeTable, record)];
|
|
105
|
+
case 1:
|
|
106
|
+
result = _a.sent();
|
|
107
|
+
// Verify record was added to cache
|
|
108
|
+
expect(transaction.recordMap(employeeTable.name)[result.id]).toEqual({
|
|
109
|
+
id: expect.any(String),
|
|
110
|
+
name: 'John Doe',
|
|
111
|
+
department: 'Engineering',
|
|
112
|
+
jobTitle: 'Software Engineer',
|
|
113
|
+
isRemote: true,
|
|
114
|
+
startDate: expect.any(Date),
|
|
115
|
+
created: expect.any(moment_1.default),
|
|
116
|
+
updated: expect.any(moment_1.default),
|
|
117
|
+
});
|
|
118
|
+
// Verify operation was queued
|
|
119
|
+
expect(transaction.ops).toHaveLength(1);
|
|
120
|
+
expect(transaction.ops[0]).toEqual({
|
|
121
|
+
name: 'insert',
|
|
122
|
+
args: [employeeTable, result],
|
|
123
|
+
});
|
|
124
|
+
// Verify callback was called
|
|
125
|
+
expect(insertCallback).toHaveBeenCalledTimes(1);
|
|
126
|
+
expect(insertCallback).toHaveBeenCalledWith(employeeTable, result);
|
|
127
|
+
return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}); });
|
|
131
|
+
it('should throw error when inserting record with duplicate id', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
|
+
var record;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
record = {
|
|
137
|
+
id: 'test-id',
|
|
138
|
+
name: 'John Doe',
|
|
139
|
+
department: 'Engineering',
|
|
140
|
+
};
|
|
141
|
+
return [4 /*yield*/, transaction.insert(employeeTable, record)];
|
|
142
|
+
case 1:
|
|
143
|
+
_a.sent();
|
|
144
|
+
return [4 /*yield*/, expect(transaction.insert(employeeTable, record)).rejects.toThrow('Attempting to insert with duplicate id: test-id, record already exists')];
|
|
145
|
+
case 2:
|
|
146
|
+
_a.sent();
|
|
147
|
+
return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}); });
|
|
151
|
+
});
|
|
152
|
+
describe('update', function () {
|
|
153
|
+
it('should update record in cached db by id and queue update operation', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
154
|
+
var original, updates, cached;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0: return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
158
|
+
name: 'John Doe',
|
|
159
|
+
department: 'Engineering',
|
|
160
|
+
isRemote: true,
|
|
161
|
+
})];
|
|
162
|
+
case 1:
|
|
163
|
+
original = _a.sent();
|
|
164
|
+
updates = {
|
|
165
|
+
id: original.id,
|
|
166
|
+
department: 'Product',
|
|
167
|
+
jobTitle: 'Product Manager',
|
|
168
|
+
};
|
|
169
|
+
transaction.update(employeeTable, updates);
|
|
170
|
+
cached = transaction.recordMap(employeeTable.name)[original.id];
|
|
171
|
+
expect(cached).toEqual({
|
|
172
|
+
id: original.id,
|
|
173
|
+
name: 'John Doe',
|
|
174
|
+
department: 'Product',
|
|
175
|
+
jobTitle: 'Product Manager',
|
|
176
|
+
isRemote: true,
|
|
177
|
+
created: expect.any(moment_1.default),
|
|
178
|
+
updated: expect.any(moment_1.default),
|
|
179
|
+
});
|
|
180
|
+
// Verify operation was queued
|
|
181
|
+
expect(transaction.ops[1]).toEqual({
|
|
182
|
+
name: 'update',
|
|
183
|
+
args: [employeeTable, updates],
|
|
184
|
+
});
|
|
185
|
+
// Verify callback was called
|
|
186
|
+
expect(updateCallback).toHaveBeenCalledTimes(1);
|
|
187
|
+
expect(updateCallback).toHaveBeenCalledWith(employeeTable, {
|
|
188
|
+
id: original.id,
|
|
189
|
+
name: 'John Doe',
|
|
190
|
+
department: 'Engineering',
|
|
191
|
+
isRemote: true,
|
|
192
|
+
created: expect.any(moment_1.default),
|
|
193
|
+
updated: expect.any(moment_1.default),
|
|
194
|
+
}, cached);
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}); });
|
|
199
|
+
it('should update records in cached db by object query and queue update operation', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
200
|
+
var updates, cachedRecords;
|
|
201
|
+
return __generator(this, function (_a) {
|
|
202
|
+
switch (_a.label) {
|
|
203
|
+
case 0:
|
|
204
|
+
// Insert two records
|
|
205
|
+
return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
206
|
+
name: 'John Doe',
|
|
207
|
+
department: 'Engineering',
|
|
208
|
+
isRemote: true,
|
|
209
|
+
})];
|
|
210
|
+
case 1:
|
|
211
|
+
// Insert two records
|
|
212
|
+
_a.sent();
|
|
213
|
+
return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
214
|
+
name: 'Jane Doe',
|
|
215
|
+
department: 'Engineering',
|
|
216
|
+
isRemote: false,
|
|
217
|
+
})];
|
|
218
|
+
case 2:
|
|
219
|
+
_a.sent();
|
|
220
|
+
updates = { jobTitle: 'Software Engineer' };
|
|
221
|
+
transaction.update(employeeTable, updates, { department: 'Engineering' });
|
|
222
|
+
cachedRecords = Object.values(transaction.recordMap(employeeTable.name));
|
|
223
|
+
cachedRecords.forEach(function (record) {
|
|
224
|
+
expect(record.jobTitle).toBe('Software Engineer');
|
|
225
|
+
});
|
|
226
|
+
// Verify operation was queued
|
|
227
|
+
expect(transaction.ops[2]).toEqual({
|
|
228
|
+
name: 'update',
|
|
229
|
+
args: [employeeTable, updates, { department: 'Engineering' }],
|
|
230
|
+
});
|
|
231
|
+
return [2 /*return*/];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}); });
|
|
235
|
+
it('should throw error when updating non-existent record by id', function () {
|
|
236
|
+
var update = { id: 'non-existent', name: 'John' };
|
|
237
|
+
expect(function () { return transaction.update(employeeTable, update); }).toThrow('Attempting to update record not in the cached db');
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
describe('delete', function () {
|
|
241
|
+
it('should remove record from cached db by id and queue delete operation', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
242
|
+
var record;
|
|
243
|
+
return __generator(this, function (_a) {
|
|
244
|
+
switch (_a.label) {
|
|
245
|
+
case 0: return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
246
|
+
name: 'John Doe',
|
|
247
|
+
department: 'Engineering',
|
|
248
|
+
})];
|
|
249
|
+
case 1:
|
|
250
|
+
record = _a.sent();
|
|
251
|
+
transaction.delete(employeeTable, { id: record.id });
|
|
252
|
+
expect(transaction.recordMap(employeeTable.name)[record.id]).toBeUndefined();
|
|
253
|
+
expect(transaction.ops[1]).toEqual({
|
|
254
|
+
name: 'delete',
|
|
255
|
+
args: [employeeTable, { id: record.id }],
|
|
256
|
+
});
|
|
257
|
+
expect(deleteCallback).toHaveBeenCalledTimes(1);
|
|
258
|
+
expect(deleteCallback).toHaveBeenCalledWith(employeeTable, record);
|
|
259
|
+
return [2 /*return*/];
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}); });
|
|
263
|
+
it('should remove records from cached db by object query and queue delete operation', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
264
|
+
var cachedRecords;
|
|
265
|
+
return __generator(this, function (_a) {
|
|
266
|
+
switch (_a.label) {
|
|
267
|
+
case 0: return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
268
|
+
name: 'John Doe',
|
|
269
|
+
department: 'Engineering',
|
|
270
|
+
isRemote: true,
|
|
271
|
+
})];
|
|
272
|
+
case 1:
|
|
273
|
+
_a.sent();
|
|
274
|
+
return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
275
|
+
name: 'Jane Doe',
|
|
276
|
+
department: 'Engineering',
|
|
277
|
+
isRemote: true,
|
|
278
|
+
})];
|
|
279
|
+
case 2:
|
|
280
|
+
_a.sent();
|
|
281
|
+
transaction.delete(employeeTable, { department: 'Engineering' });
|
|
282
|
+
cachedRecords = Object.values(transaction.recordMap(employeeTable.name));
|
|
283
|
+
expect(cachedRecords).toHaveLength(0);
|
|
284
|
+
expect(transaction.ops[2]).toEqual({
|
|
285
|
+
name: 'delete',
|
|
286
|
+
args: [employeeTable, { department: 'Engineering' }],
|
|
287
|
+
});
|
|
288
|
+
return [2 /*return*/];
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}); });
|
|
292
|
+
});
|
|
293
|
+
describe('cache integrity', function () {
|
|
294
|
+
it('should preserve unspecified fields during partial updates', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
295
|
+
var record, cached;
|
|
296
|
+
return __generator(this, function (_a) {
|
|
297
|
+
switch (_a.label) {
|
|
298
|
+
case 0: return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
299
|
+
name: 'John Doe',
|
|
300
|
+
department: 'Engineering',
|
|
301
|
+
jobTitle: 'Software Engineer',
|
|
302
|
+
isRemote: true,
|
|
303
|
+
startDate: new Date('2024-01-01'),
|
|
304
|
+
})];
|
|
305
|
+
case 1:
|
|
306
|
+
record = _a.sent();
|
|
307
|
+
// Perform a partial update
|
|
308
|
+
transaction.update(employeeTable, {
|
|
309
|
+
id: record.id,
|
|
310
|
+
department: 'Product',
|
|
311
|
+
});
|
|
312
|
+
cached = transaction.recordMap(employeeTable.name)[record.id];
|
|
313
|
+
expect(cached).toEqual({
|
|
314
|
+
id: record.id,
|
|
315
|
+
name: 'John Doe',
|
|
316
|
+
department: 'Product',
|
|
317
|
+
jobTitle: 'Software Engineer',
|
|
318
|
+
isRemote: true,
|
|
319
|
+
startDate: expect.any(Date),
|
|
320
|
+
created: expect.any(moment_1.default),
|
|
321
|
+
updated: expect.any(moment_1.default),
|
|
322
|
+
});
|
|
323
|
+
return [2 /*return*/];
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}); });
|
|
327
|
+
it('should maintain referential integrity in the cache across operations', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
328
|
+
var record, initialCacheRef, references, expectedState;
|
|
329
|
+
return __generator(this, function (_a) {
|
|
330
|
+
switch (_a.label) {
|
|
331
|
+
case 0: return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
332
|
+
name: 'John Doe',
|
|
333
|
+
department: 'Engineering',
|
|
334
|
+
})];
|
|
335
|
+
case 1:
|
|
336
|
+
record = _a.sent();
|
|
337
|
+
initialCacheRef = transaction.recordMap(employeeTable.name)[record.id];
|
|
338
|
+
references = [initialCacheRef, transaction.recordMap(employeeTable.name)[record.id]];
|
|
339
|
+
// Perform multiple updates
|
|
340
|
+
transaction.update(employeeTable, {
|
|
341
|
+
id: record.id,
|
|
342
|
+
jobTitle: 'Software Engineer',
|
|
343
|
+
});
|
|
344
|
+
transaction.update(employeeTable, {
|
|
345
|
+
id: record.id,
|
|
346
|
+
isRemote: true,
|
|
347
|
+
});
|
|
348
|
+
// Get another reference after updates
|
|
349
|
+
references.push(transaction.recordMap(employeeTable.name)[record.id]);
|
|
350
|
+
expectedState = {
|
|
351
|
+
id: record.id,
|
|
352
|
+
name: 'John Doe',
|
|
353
|
+
department: 'Engineering',
|
|
354
|
+
jobTitle: 'Software Engineer',
|
|
355
|
+
isRemote: true,
|
|
356
|
+
created: expect.any(moment_1.default),
|
|
357
|
+
updated: expect.any(moment_1.default),
|
|
358
|
+
};
|
|
359
|
+
// Verify all references have the same, updated state
|
|
360
|
+
references.forEach(function (ref) {
|
|
361
|
+
expect(ref).toEqual(expectedState);
|
|
362
|
+
});
|
|
363
|
+
// Verify all references point to the exact same object
|
|
364
|
+
references.forEach(function (ref) {
|
|
365
|
+
expect(ref).toBe(initialCacheRef);
|
|
366
|
+
});
|
|
367
|
+
return [2 /*return*/];
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}); });
|
|
371
|
+
it('should maintain referential integrity when updating via query', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
372
|
+
var record, initialRef, currentRef;
|
|
373
|
+
return __generator(this, function (_a) {
|
|
374
|
+
switch (_a.label) {
|
|
375
|
+
case 0: return [4 /*yield*/, transaction.insert(employeeTable, {
|
|
376
|
+
name: 'John Doe',
|
|
377
|
+
department: 'Engineering',
|
|
378
|
+
isRemote: true,
|
|
379
|
+
})];
|
|
380
|
+
case 1:
|
|
381
|
+
record = _a.sent();
|
|
382
|
+
initialRef = transaction.recordMap(employeeTable.name)[record.id];
|
|
383
|
+
// Update via query
|
|
384
|
+
transaction.update(employeeTable, { jobTitle: 'Remote Engineer' }, { department: 'Engineering', isRemote: true });
|
|
385
|
+
currentRef = transaction.recordMap(employeeTable.name)[record.id];
|
|
386
|
+
// Verify both references point to the same object
|
|
387
|
+
expect(currentRef).toBe(initialRef);
|
|
388
|
+
// Verify the object was updated correctly
|
|
389
|
+
expect(currentRef).toEqual({
|
|
390
|
+
id: record.id,
|
|
391
|
+
name: 'John Doe',
|
|
392
|
+
department: 'Engineering',
|
|
393
|
+
isRemote: true,
|
|
394
|
+
jobTitle: 'Remote Engineer',
|
|
395
|
+
created: expect.any(moment_1.default),
|
|
396
|
+
updated: expect.any(moment_1.default),
|
|
397
|
+
});
|
|
398
|
+
return [2 /*return*/];
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
}); });
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
//# sourceMappingURL=TransactionDb.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionDb.test.js","sourceRoot":"","sources":["../../test/TransactionDb.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;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ACrD,IAAI,EAAE,UAAU;4BAChB,UAAU,EAAE,aAAa;4BACzB,QAAQ,EAAE,IAAI;yBACf,CAAC,EAAA;;wBAJI,MAAM,GAAG,SAIb;wBAGI,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;wBAExE,mBAAmB;wBACnB,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;wBAG5G,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;wBAExE,kDAAkD;wBAClD,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;wBAEpC,0CAA0C;wBAC1C,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;4BACzB,EAAE,EAAE,MAAM,CAAC,EAAE;4BACb,IAAI,EAAE,UAAU;4BAChB,UAAU,EAAE,aAAa;4BACzB,QAAQ,EAAE,IAAI;4BACd,QAAQ,EAAE,iBAAiB;4BAC3B,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,gBAAM,CAAC;4BAC3B,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,gBAAM,CAAC;yBAC5B,CAAC,CAAC;;;;aACJ,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { DbDriver } from '../../src/Db';
|
|
2
|
+
import { Record } from '../../src/Record';
|
|
3
|
+
import { Table } from '../../src/Table';
|
|
4
|
+
interface Employee extends Record {
|
|
5
|
+
name: string;
|
|
6
|
+
department?: string;
|
|
7
|
+
jobTitle?: string | null;
|
|
8
|
+
isRemote?: boolean;
|
|
9
|
+
startDate?: Date;
|
|
10
|
+
object?: string;
|
|
11
|
+
}
|
|
12
|
+
declare class EmployeeTestTable extends Table<Employee> {
|
|
13
|
+
name: string;
|
|
14
|
+
columns: {
|
|
15
|
+
id: import("../../src/Table").Column<string, any>;
|
|
16
|
+
created: import("../../src/Table").Column<import("moment").Moment, any>;
|
|
17
|
+
updated: import("../../src/Table").Column<import("moment").Moment, any>;
|
|
18
|
+
} & {} & {
|
|
19
|
+
object: import("../../src/Table").Column<string | undefined, any>;
|
|
20
|
+
name: import("../../src/Table").Column<string, any>;
|
|
21
|
+
department: import("../../src/Table").Column<string | undefined, any>;
|
|
22
|
+
jobTitle: import("../../src/Table").Column<string | null | undefined, any>;
|
|
23
|
+
isRemote: import("../../src/Table").Column<boolean | undefined, any>;
|
|
24
|
+
startDate: import("../../src/Table").Column<Date | undefined, any>;
|
|
25
|
+
} & {};
|
|
26
|
+
}
|
|
27
|
+
interface ReservedWordTest extends Record {
|
|
28
|
+
name: string;
|
|
29
|
+
order?: string;
|
|
30
|
+
select?: string;
|
|
31
|
+
join?: string;
|
|
32
|
+
}
|
|
33
|
+
declare class ReservedWordTestTable extends Table<ReservedWordTest> {
|
|
34
|
+
name: string;
|
|
35
|
+
columns: {
|
|
36
|
+
id: import("../../src/Table").Column<string, any>;
|
|
37
|
+
created: import("../../src/Table").Column<import("moment").Moment, any>;
|
|
38
|
+
updated: import("../../src/Table").Column<import("moment").Moment, any>;
|
|
39
|
+
} & {} & {
|
|
40
|
+
select: import("../../src/Table").Column<string | undefined, any>;
|
|
41
|
+
name: import("../../src/Table").Column<string, any>;
|
|
42
|
+
order: import("../../src/Table").Column<string | undefined, any>;
|
|
43
|
+
join: import("../../src/Table").Column<string | undefined, any>;
|
|
44
|
+
} & {};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Used for testing purposes only.
|
|
48
|
+
* */
|
|
49
|
+
export declare const getTransactionTestTable: (tableName: string) => EmployeeTestTable | ReservedWordTestTable;
|
|
50
|
+
export declare const transactionTests: (driver: DbDriver, dropTable: (table: Table<any>) => Promise<void>) => () => void;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=TransactionTests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionTests.d.ts","sourceRoot":"","sources":["../../../test/reusable/TransactionTests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAM,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAqB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,UAAU,QAAS,SAAQ,MAAM;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,cAAM,iBAAkB,SAAQ,KAAK,CAAC,QAAQ,CAAC;IAC7C,IAAI,SAAkC;IACtC,OAAO;;;;;;;;;;;WAOJ;CACJ;AAED,UAAU,gBAAiB,SAAQ,MAAM;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,cAAM,qBAAsB,SAAQ,KAAK,CAAC,gBAAgB,CAAC;IACzD,IAAI,SAAuC;IAC3C,OAAO;;;;;;;;;WAKJ;CACJ;AAED;;MAEM;AACN,eAAO,MAAM,uBAAuB,cAAe,MAAM,8CAYxD,CAAC;AAEF,eAAO,MAAM,gBAAgB,WAAY,QAAQ,qBAAqB,MAAM,GAAG,CAAC,KAAK,QAAQ,IAAI,CAAC,eA4KjG,CAAC"}
|