remult 3.3.8 → 3.3.10
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.
|
@@ -2,6 +2,8 @@ import { dbNamesOf, shouldCreateEntity, shouldNotCreateField, } from '../src/fil
|
|
|
2
2
|
import { isAutoIncrement } from '../src/remult3/RepositoryImplementation.js';
|
|
3
3
|
import { ValueConverters } from '../src/valueConverters.js';
|
|
4
4
|
export function postgresColumnSyntax(x, dbName) {
|
|
5
|
+
if (isAutoIncrement(x))
|
|
6
|
+
return dbName + ' serial';
|
|
5
7
|
let result = dbName;
|
|
6
8
|
if (x.valueType == Number) {
|
|
7
9
|
if (!x.valueConverter.fieldTypeInDb)
|
|
@@ -129,11 +131,7 @@ export class PostgresSchemaBuilder {
|
|
|
129
131
|
if (result.length != 0)
|
|
130
132
|
result += ',';
|
|
131
133
|
result += '\r\n ';
|
|
132
|
-
|
|
133
|
-
result += e.$dbNameOf(x) + ' serial';
|
|
134
|
-
else {
|
|
135
|
-
result += postgresColumnSyntax(x, e.$dbNameOf(x));
|
|
136
|
-
}
|
|
134
|
+
result += postgresColumnSyntax(x, e.$dbNameOf(x));
|
|
137
135
|
}
|
|
138
136
|
}
|
|
139
137
|
result += `,\r\n primary key (${entity.idMetadata.fields
|
|
@@ -25,7 +25,9 @@ export class JsonEntityIndexedDbStorage {
|
|
|
25
25
|
const attempt = async () => {
|
|
26
26
|
const db = await this.init();
|
|
27
27
|
return new Promise((resolve, reject) => {
|
|
28
|
-
const
|
|
28
|
+
const tx = db.transaction([this.storeName], mode);
|
|
29
|
+
tx.onabort = () => reject(tx.error);
|
|
30
|
+
const request = op(tx.objectStore(this.storeName));
|
|
29
31
|
request.onerror = () => reject(request.error);
|
|
30
32
|
request.onsuccess = () => resolve(request.result ?? null);
|
|
31
33
|
});
|
|
@@ -34,8 +36,6 @@ export class JsonEntityIndexedDbStorage {
|
|
|
34
36
|
return await attempt();
|
|
35
37
|
}
|
|
36
38
|
catch (err) {
|
|
37
|
-
if (err?.name !== 'InvalidStateError')
|
|
38
|
-
throw err;
|
|
39
39
|
this.db = undefined;
|
|
40
40
|
return await attempt();
|
|
41
41
|
}
|
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@ var filter_consumer_bridge_to_sql_request_js_1 = require("../src/filter/filter-c
|
|
|
7
7
|
var RepositoryImplementation_js_1 = require("../src/remult3/RepositoryImplementation.js");
|
|
8
8
|
var valueConverters_js_1 = require("../src/valueConverters.js");
|
|
9
9
|
function postgresColumnSyntax(x, dbName) {
|
|
10
|
+
if ((0, RepositoryImplementation_js_1.isAutoIncrement)(x))
|
|
11
|
+
return dbName + ' serial';
|
|
10
12
|
var result = dbName;
|
|
11
13
|
if (x.valueType == Number) {
|
|
12
14
|
if (!x.valueConverter.fieldTypeInDb)
|
|
@@ -218,11 +220,7 @@ var PostgresSchemaBuilder = /** @class */ (function () {
|
|
|
218
220
|
if (result.length != 0)
|
|
219
221
|
result += ',';
|
|
220
222
|
result += '\r\n ';
|
|
221
|
-
|
|
222
|
-
result += e.$dbNameOf(x) + ' serial';
|
|
223
|
-
else {
|
|
224
|
-
result += postgresColumnSyntax(x, e.$dbNameOf(x));
|
|
225
|
-
}
|
|
223
|
+
result += postgresColumnSyntax(x, e.$dbNameOf(x));
|
|
226
224
|
}
|
|
227
225
|
}
|
|
228
226
|
}
|
|
@@ -41,7 +41,9 @@ var JsonEntityIndexedDbStorage = /** @class */ (function () {
|
|
|
41
41
|
case 1:
|
|
42
42
|
db = _a.sent();
|
|
43
43
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
44
|
-
var
|
|
44
|
+
var tx = db.transaction([_this.storeName], mode);
|
|
45
|
+
tx.onabort = function () { return reject(tx.error); };
|
|
46
|
+
var request = op(tx.objectStore(_this.storeName));
|
|
45
47
|
request.onerror = function () { return reject(request.error); };
|
|
46
48
|
request.onsuccess = function () { var _a; return resolve((_a = request.result) !== null && _a !== void 0 ? _a : null); };
|
|
47
49
|
})];
|
|
@@ -55,8 +57,6 @@ var JsonEntityIndexedDbStorage = /** @class */ (function () {
|
|
|
55
57
|
case 2: return [2 /*return*/, _a.sent()];
|
|
56
58
|
case 3:
|
|
57
59
|
err_1 = _a.sent();
|
|
58
|
-
if ((err_1 === null || err_1 === void 0 ? void 0 : err_1.name) !== 'InvalidStateError')
|
|
59
|
-
throw err_1;
|
|
60
60
|
this.db = undefined;
|
|
61
61
|
return [4 /*yield*/, attempt()];
|
|
62
62
|
case 4: return [2 /*return*/, _a.sent()];
|