remult 0.22.11-exp2.0 → 0.22.12
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/esm/postgres/schema-builder.js +1 -0
- package/esm/remult-knex/index.js +2 -1
- package/esm/remult-mongo.d.ts +1 -1
- package/esm/remult-mongo.js +15 -4
- package/esm/server/JsonEntityFileStorage.d.ts +2 -2
- package/esm/server/JsonEntityFileStorage.js +4 -6
- package/esm/src/data-providers/json-data-provider.d.ts +2 -2
- package/esm/src/data-providers/json-data-provider.js +8 -8
- package/esm/src/remult3/Fields.d.ts +0 -20
- package/esm/src/remult3/remult3.js +1 -0
- package/package.json +1 -1
- package/postgres/schema-builder.js +1 -1
- package/remult-knex/index.js +11 -6
- package/remult-mongo.d.ts +1 -1
- package/remult-mongo.js +15 -4
- package/server/JsonEntityFileStorage.d.ts +2 -2
- package/server/JsonEntityFileStorage.js +11 -35
- package/src/data-providers/json-data-provider.d.ts +2 -2
- package/src/data-providers/json-data-provider.js +16 -39
- package/src/remult3/Fields.d.ts +0 -20
- package/src/remult3/remult3.js +1 -0
package/esm/remult-knex/index.js
CHANGED
|
@@ -313,7 +313,7 @@ export class KnexSchemaBuilder {
|
|
|
313
313
|
if (!remult)
|
|
314
314
|
remult = remultContext;
|
|
315
315
|
const entities = allEntities.map((x) => remult.repo(x).metadata);
|
|
316
|
-
this.ensureSchema(entities);
|
|
316
|
+
await this.ensureSchema(entities);
|
|
317
317
|
}
|
|
318
318
|
async ensureSchema(entities) {
|
|
319
319
|
for (const entity of entities) {
|
|
@@ -328,6 +328,7 @@ export class KnexSchemaBuilder {
|
|
|
328
328
|
}
|
|
329
329
|
catch (err) {
|
|
330
330
|
console.error('failed ensure schema of ' + e.$entityName + ' ', err);
|
|
331
|
+
throw err;
|
|
331
332
|
}
|
|
332
333
|
}
|
|
333
334
|
}
|
package/esm/remult-mongo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClientSession, type Db, type MongoClient } from 'mongodb';
|
|
2
2
|
import type { DataProvider, EntityDataProvider, EntityFilter, EntityMetadata, Remult } from '.';
|
|
3
3
|
import type { RepositoryOverloads } from './src/remult3/RepositoryImplementation';
|
|
4
4
|
export declare class MongoDataProvider implements DataProvider {
|
package/esm/remult-mongo.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ObjectId, } from 'mongodb';
|
|
1
2
|
import { CompoundIdField, Filter } from '.';
|
|
2
3
|
import { dbNamesOf } from './src/filter/filter-consumer-bridge-to-sql-request';
|
|
3
4
|
import { remult as remultContext } from './src/remult-proxy';
|
|
@@ -72,14 +73,14 @@ class MongoEntityDataProvider {
|
|
|
72
73
|
let val = row[nameProvider.$dbNameOf(col)];
|
|
73
74
|
if (isNull(val))
|
|
74
75
|
val = null;
|
|
75
|
-
result[col.key] =
|
|
76
|
+
result[col.key] = fromDb(col, val);
|
|
76
77
|
}
|
|
77
78
|
return result;
|
|
78
79
|
}
|
|
79
80
|
translateToDb(row, nameProvider) {
|
|
80
81
|
let result = {};
|
|
81
82
|
for (const col of this.entity.fields) {
|
|
82
|
-
let val =
|
|
83
|
+
let val = toDb(col, row[col.key]);
|
|
83
84
|
if (val === null)
|
|
84
85
|
val = NULL;
|
|
85
86
|
result[nameProvider.$dbNameOf(col)] = val;
|
|
@@ -218,7 +219,7 @@ class FilterConsumerBridgeToMongo {
|
|
|
218
219
|
isIn(col, val) {
|
|
219
220
|
this.result.push(() => ({
|
|
220
221
|
[this.nameProvider.$dbNameOf(col)]: {
|
|
221
|
-
$in: val.map((x) =>
|
|
222
|
+
$in: val.map((x) => toDb(col, x)),
|
|
222
223
|
},
|
|
223
224
|
}));
|
|
224
225
|
}
|
|
@@ -250,7 +251,7 @@ class FilterConsumerBridgeToMongo {
|
|
|
250
251
|
add(col, val, operator) {
|
|
251
252
|
this.result.push(() => ({
|
|
252
253
|
[this.nameProvider.$dbNameOf(col)]: {
|
|
253
|
-
[operator]: isNull(val) ? val :
|
|
254
|
+
[operator]: isNull(val) ? val : toDb(col, val),
|
|
254
255
|
},
|
|
255
256
|
}));
|
|
256
257
|
}
|
|
@@ -267,3 +268,13 @@ class FilterConsumerBridgeToMongo {
|
|
|
267
268
|
// })());
|
|
268
269
|
}
|
|
269
270
|
}
|
|
271
|
+
function toDb(col, val) {
|
|
272
|
+
if (col.valueConverter.fieldTypeInDb == 'dbid')
|
|
273
|
+
return val ? new ObjectId(val) : val === null ? null : undefined;
|
|
274
|
+
return col.valueConverter.toDb(val);
|
|
275
|
+
}
|
|
276
|
+
function fromDb(col, val) {
|
|
277
|
+
if (col.valueConverter.fieldTypeInDb == 'dbid')
|
|
278
|
+
return val ? val.toHexString() : val === null ? null : undefined;
|
|
279
|
+
return col.valueConverter.fromDb(val);
|
|
280
|
+
}
|
|
@@ -2,8 +2,8 @@ import type { JsonEntityStorage } from '../index';
|
|
|
2
2
|
import { JsonDataProvider } from '../index';
|
|
3
3
|
export declare class JsonEntityFileStorage implements JsonEntityStorage {
|
|
4
4
|
private folderPath;
|
|
5
|
-
getItem(entityDbName: string):
|
|
6
|
-
setItem(entityDbName: string, json: string):
|
|
5
|
+
getItem(entityDbName: string): string;
|
|
6
|
+
setItem(entityDbName: string, json: string): void;
|
|
7
7
|
constructor(folderPath: string);
|
|
8
8
|
}
|
|
9
9
|
export declare class JsonFileDataProvider extends JsonDataProvider {
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
1
3
|
import { JsonDataProvider } from '../index';
|
|
2
4
|
export class JsonEntityFileStorage {
|
|
3
5
|
folderPath;
|
|
4
|
-
|
|
5
|
-
const path = await import('path');
|
|
6
|
-
const fs = await import('fs');
|
|
6
|
+
getItem(entityDbName) {
|
|
7
7
|
let fn = path.join(this.folderPath, entityDbName) + '.json';
|
|
8
8
|
if (fs.existsSync(fn)) {
|
|
9
9
|
return fs.readFileSync(fn).toString();
|
|
10
10
|
}
|
|
11
11
|
return undefined;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const path = await import('path');
|
|
15
|
-
const fs = await import('fs');
|
|
13
|
+
setItem(entityDbName, json) {
|
|
16
14
|
if (!fs.existsSync(this.folderPath)) {
|
|
17
15
|
fs.mkdirSync(this.folderPath);
|
|
18
16
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DataProvider, EntityDataProvider } from '../data-interfaces';
|
|
2
2
|
import type { EntityMetadata } from '../remult3/remult3';
|
|
3
3
|
export interface JsonEntityStorage {
|
|
4
|
-
getItem(entityDbName: string):
|
|
5
|
-
setItem(entityDbName: string, json: string):
|
|
4
|
+
getItem(entityDbName: string): string | null;
|
|
5
|
+
setItem(entityDbName: string, json: string): any;
|
|
6
6
|
}
|
|
7
7
|
export declare class JsonDataProvider implements DataProvider {
|
|
8
8
|
private storage;
|
|
@@ -21,11 +21,11 @@ class JsonEntityDataProvider {
|
|
|
21
21
|
async loadEntityData(what) {
|
|
22
22
|
let data = [];
|
|
23
23
|
let dbName = await this.entity.getDbName();
|
|
24
|
-
let s =
|
|
24
|
+
let s = this.helper.getItem(dbName);
|
|
25
25
|
if (s)
|
|
26
26
|
data = JSON.parse(s);
|
|
27
27
|
let dp = new ArrayEntityDataProvider(this.entity, data);
|
|
28
|
-
return what(dp,
|
|
28
|
+
return what(dp, () => this.helper.setItem(dbName, JSON.stringify(data, undefined, 2)));
|
|
29
29
|
}
|
|
30
30
|
p = Promise.resolve();
|
|
31
31
|
find(options) {
|
|
@@ -35,20 +35,20 @@ class JsonEntityDataProvider {
|
|
|
35
35
|
return (this.p = this.p.then(() => this.loadEntityData((dp, save) => dp.count(where))));
|
|
36
36
|
}
|
|
37
37
|
update(id, data) {
|
|
38
|
-
return (this.p = this.p.then(() => this.loadEntityData((dp, save) => dp.update(id, data).then(
|
|
39
|
-
|
|
38
|
+
return (this.p = this.p.then(() => this.loadEntityData((dp, save) => dp.update(id, data).then((x) => {
|
|
39
|
+
save();
|
|
40
40
|
return x;
|
|
41
41
|
}))));
|
|
42
42
|
}
|
|
43
43
|
delete(id) {
|
|
44
|
-
return (this.p = this.p.then(() => this.loadEntityData((dp, save) => dp.delete(id).then(
|
|
45
|
-
|
|
44
|
+
return (this.p = this.p.then(() => this.loadEntityData((dp, save) => dp.delete(id).then((x) => {
|
|
45
|
+
save();
|
|
46
46
|
return x;
|
|
47
47
|
}))));
|
|
48
48
|
}
|
|
49
49
|
async insert(data) {
|
|
50
|
-
return (this.p = this.p.then(() => this.loadEntityData((dp, save) => dp.insert(data).then(
|
|
51
|
-
|
|
50
|
+
return (this.p = this.p.then(() => this.loadEntityData((dp, save) => dp.insert(data).then((x) => {
|
|
51
|
+
save();
|
|
52
52
|
return x;
|
|
53
53
|
}))));
|
|
54
54
|
}
|
|
@@ -54,26 +54,6 @@ export declare class Relations {
|
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
57
|
-
/**
|
|
58
|
-
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
59
|
-
* This overload allows you to define the relation using options.
|
|
60
|
-
* If no field or fields are provided, it will automatically create a field in the database
|
|
61
|
-
* to represent the relation.
|
|
62
|
-
*
|
|
63
|
-
* @param toEntityType A function that returns the target entity type.
|
|
64
|
-
* @param options An object containing options for configuring the to-one relation.
|
|
65
|
-
* - field (Optional): The name of the field in the related entity that corresponds to this relation.
|
|
66
|
-
* @returns A decorator function to apply the virtual to-one relation to an entity field.
|
|
67
|
-
*
|
|
68
|
-
* Example usage:
|
|
69
|
-
* ```
|
|
70
|
-
* @Relations.toOne(() => Customer, {
|
|
71
|
-
* field: "customerId",
|
|
72
|
-
* })
|
|
73
|
-
* customer?: Customer;
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
77
57
|
/**
|
|
78
58
|
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
79
59
|
* If no field or fields are provided, it will automatically create a field in the database
|
package/package.json
CHANGED
|
@@ -179,7 +179,7 @@ var PostgresSchemaBuilder = /** @class */ (function () {
|
|
|
179
179
|
case 7:
|
|
180
180
|
err_1 = _b.sent();
|
|
181
181
|
console.error('failed verify structure of ' + e.$entityName + ' ', err_1);
|
|
182
|
-
|
|
182
|
+
throw err_1;
|
|
183
183
|
case 8:
|
|
184
184
|
entities_1_1 = entities_1.next();
|
|
185
185
|
return [3 /*break*/, 1];
|
package/remult-knex/index.js
CHANGED
|
@@ -609,11 +609,16 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
609
609
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
610
610
|
var entities;
|
|
611
611
|
return tslib_1.__generator(this, function (_a) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
612
|
+
switch (_a.label) {
|
|
613
|
+
case 0:
|
|
614
|
+
if (!remult)
|
|
615
|
+
remult = remult_proxy_1.remult;
|
|
616
|
+
entities = context_1.allEntities.map(function (x) { return remult.repo(x).metadata; });
|
|
617
|
+
return [4 /*yield*/, this.ensureSchema(entities)];
|
|
618
|
+
case 1:
|
|
619
|
+
_a.sent();
|
|
620
|
+
return [2 /*return*/];
|
|
621
|
+
}
|
|
617
622
|
});
|
|
618
623
|
});
|
|
619
624
|
};
|
|
@@ -649,7 +654,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
649
654
|
case 7:
|
|
650
655
|
err_2 = _b.sent();
|
|
651
656
|
console.error('failed ensure schema of ' + e.$entityName + ' ', err_2);
|
|
652
|
-
|
|
657
|
+
throw err_2;
|
|
653
658
|
case 8:
|
|
654
659
|
entities_1_1 = entities_1.next();
|
|
655
660
|
return [3 /*break*/, 1];
|
package/remult-mongo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ClientSession, type Db, type MongoClient } from 'mongodb';
|
|
2
2
|
import type { DataProvider, EntityDataProvider, EntityFilter, EntityMetadata, Remult } from '.';
|
|
3
3
|
import type { RepositoryOverloads } from './src/remult3/RepositoryImplementation';
|
|
4
4
|
export declare class MongoDataProvider implements DataProvider {
|
package/remult-mongo.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoDataProvider = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var mongodb_1 = require("mongodb");
|
|
5
6
|
var _1 = require(".");
|
|
6
7
|
var filter_consumer_bridge_to_sql_request_1 = require("./src/filter/filter-consumer-bridge-to-sql-request");
|
|
7
8
|
var remult_proxy_1 = require("./src/remult-proxy");
|
|
@@ -111,7 +112,7 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
111
112
|
var val = row[nameProvider.$dbNameOf(col)];
|
|
112
113
|
if (isNull(val))
|
|
113
114
|
val = null;
|
|
114
|
-
result[col.key] =
|
|
115
|
+
result[col.key] = fromDb(col, val);
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -129,7 +130,7 @@ var MongoEntityDataProvider = /** @class */ (function () {
|
|
|
129
130
|
try {
|
|
130
131
|
for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
131
132
|
var col = _c.value;
|
|
132
|
-
var val =
|
|
133
|
+
var val = toDb(col, row[col.key]);
|
|
133
134
|
if (val === null)
|
|
134
135
|
val = NULL;
|
|
135
136
|
result[nameProvider.$dbNameOf(col)] = val;
|
|
@@ -458,7 +459,7 @@ var FilterConsumerBridgeToMongo = /** @class */ (function () {
|
|
|
458
459
|
var _a;
|
|
459
460
|
return (_a = {},
|
|
460
461
|
_a[_this.nameProvider.$dbNameOf(col)] = {
|
|
461
|
-
$in: val.map(function (x) { return
|
|
462
|
+
$in: val.map(function (x) { return toDb(col, x); }),
|
|
462
463
|
},
|
|
463
464
|
_a);
|
|
464
465
|
});
|
|
@@ -494,7 +495,7 @@ var FilterConsumerBridgeToMongo = /** @class */ (function () {
|
|
|
494
495
|
var _a, _b;
|
|
495
496
|
return (_a = {},
|
|
496
497
|
_a[_this.nameProvider.$dbNameOf(col)] = (_b = {},
|
|
497
|
-
_b[operator] = isNull(val) ? val :
|
|
498
|
+
_b[operator] = isNull(val) ? val : toDb(col, val),
|
|
498
499
|
_b),
|
|
499
500
|
_a);
|
|
500
501
|
});
|
|
@@ -513,3 +514,13 @@ var FilterConsumerBridgeToMongo = /** @class */ (function () {
|
|
|
513
514
|
};
|
|
514
515
|
return FilterConsumerBridgeToMongo;
|
|
515
516
|
}());
|
|
517
|
+
function toDb(col, val) {
|
|
518
|
+
if (col.valueConverter.fieldTypeInDb == 'dbid')
|
|
519
|
+
return val ? new mongodb_1.ObjectId(val) : val === null ? null : undefined;
|
|
520
|
+
return col.valueConverter.toDb(val);
|
|
521
|
+
}
|
|
522
|
+
function fromDb(col, val) {
|
|
523
|
+
if (col.valueConverter.fieldTypeInDb == 'dbid')
|
|
524
|
+
return val ? val.toHexString() : val === null ? null : undefined;
|
|
525
|
+
return col.valueConverter.fromDb(val);
|
|
526
|
+
}
|
|
@@ -2,8 +2,8 @@ import type { JsonEntityStorage } from '../index';
|
|
|
2
2
|
import { JsonDataProvider } from '../index';
|
|
3
3
|
export declare class JsonEntityFileStorage implements JsonEntityStorage {
|
|
4
4
|
private folderPath;
|
|
5
|
-
getItem(entityDbName: string):
|
|
6
|
-
setItem(entityDbName: string, json: string):
|
|
5
|
+
getItem(entityDbName: string): string;
|
|
6
|
+
setItem(entityDbName: string, json: string): void;
|
|
7
7
|
constructor(folderPath: string);
|
|
8
8
|
}
|
|
9
9
|
export declare class JsonFileDataProvider extends JsonDataProvider {
|
|
@@ -2,49 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonFileDataProvider = exports.JsonEntityFileStorage = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
var path = tslib_1.__importStar(require("path"));
|
|
5
7
|
var index_1 = require("../index");
|
|
6
8
|
var JsonEntityFileStorage = /** @class */ (function () {
|
|
7
9
|
function JsonEntityFileStorage(folderPath) {
|
|
8
10
|
this.folderPath = folderPath;
|
|
9
11
|
}
|
|
10
12
|
JsonEntityFileStorage.prototype.getItem = function (entityDbName) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
case 1:
|
|
17
|
-
path = _a.sent();
|
|
18
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return tslib_1.__importStar(require('fs')); })];
|
|
19
|
-
case 2:
|
|
20
|
-
fs = _a.sent();
|
|
21
|
-
fn = path.join(this.folderPath, entityDbName) + '.json';
|
|
22
|
-
if (fs.existsSync(fn)) {
|
|
23
|
-
return [2 /*return*/, fs.readFileSync(fn).toString()];
|
|
24
|
-
}
|
|
25
|
-
return [2 /*return*/, undefined];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
13
|
+
var fn = path.join(this.folderPath, entityDbName) + '.json';
|
|
14
|
+
if (fs.existsSync(fn)) {
|
|
15
|
+
return fs.readFileSync(fn).toString();
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
29
18
|
};
|
|
30
19
|
JsonEntityFileStorage.prototype.setItem = function (entityDbName, json) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return tslib_1.__importStar(require('path')); })];
|
|
36
|
-
case 1:
|
|
37
|
-
path = _a.sent();
|
|
38
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return tslib_1.__importStar(require('fs')); })];
|
|
39
|
-
case 2:
|
|
40
|
-
fs = _a.sent();
|
|
41
|
-
if (!fs.existsSync(this.folderPath)) {
|
|
42
|
-
fs.mkdirSync(this.folderPath);
|
|
43
|
-
}
|
|
44
|
-
return [2 /*return*/, fs.writeFileSync(path.join(this.folderPath, entityDbName) + '.json', json)];
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
20
|
+
if (!fs.existsSync(this.folderPath)) {
|
|
21
|
+
fs.mkdirSync(this.folderPath);
|
|
22
|
+
}
|
|
23
|
+
return fs.writeFileSync(path.join(this.folderPath, entityDbName) + '.json', json);
|
|
48
24
|
};
|
|
49
25
|
return JsonEntityFileStorage;
|
|
50
26
|
}());
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DataProvider, EntityDataProvider } from '../data-interfaces';
|
|
2
2
|
import type { EntityMetadata } from '../remult3/remult3';
|
|
3
3
|
export interface JsonEntityStorage {
|
|
4
|
-
getItem(entityDbName: string):
|
|
5
|
-
setItem(entityDbName: string, json: string):
|
|
4
|
+
getItem(entityDbName: string): string | null;
|
|
5
|
+
setItem(entityDbName: string, json: string): any;
|
|
6
6
|
}
|
|
7
7
|
export declare class JsonDataProvider implements DataProvider {
|
|
8
8
|
private storage;
|
|
@@ -42,18 +42,13 @@ var JsonEntityDataProvider = /** @class */ (function () {
|
|
|
42
42
|
return [4 /*yield*/, this.entity.getDbName()];
|
|
43
43
|
case 1:
|
|
44
44
|
dbName = _a.sent();
|
|
45
|
-
|
|
46
|
-
case 2:
|
|
47
|
-
s = _a.sent();
|
|
45
|
+
s = this.helper.getItem(dbName);
|
|
48
46
|
if (s)
|
|
49
47
|
data = JSON.parse(s);
|
|
50
48
|
dp = new array_entity_data_provider_1.ArrayEntityDataProvider(this.entity, data);
|
|
51
|
-
return [2 /*return*/, what(dp, function () {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
55
|
-
}
|
|
56
|
-
}); }); })];
|
|
49
|
+
return [2 /*return*/, what(dp, function () {
|
|
50
|
+
return _this.helper.setItem(dbName, JSON.stringify(data, undefined, 2));
|
|
51
|
+
})];
|
|
57
52
|
}
|
|
58
53
|
});
|
|
59
54
|
});
|
|
@@ -74,16 +69,10 @@ var JsonEntityDataProvider = /** @class */ (function () {
|
|
|
74
69
|
var _this = this;
|
|
75
70
|
return (this.p = this.p.then(function () {
|
|
76
71
|
return _this.loadEntityData(function (dp, save) {
|
|
77
|
-
return dp.update(id, data).then(function (x) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
case 1:
|
|
82
|
-
_a.sent();
|
|
83
|
-
return [2 /*return*/, x];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}); });
|
|
72
|
+
return dp.update(id, data).then(function (x) {
|
|
73
|
+
save();
|
|
74
|
+
return x;
|
|
75
|
+
});
|
|
87
76
|
});
|
|
88
77
|
}));
|
|
89
78
|
};
|
|
@@ -91,16 +80,10 @@ var JsonEntityDataProvider = /** @class */ (function () {
|
|
|
91
80
|
var _this = this;
|
|
92
81
|
return (this.p = this.p.then(function () {
|
|
93
82
|
return _this.loadEntityData(function (dp, save) {
|
|
94
|
-
return dp.delete(id).then(function (x) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
case 1:
|
|
99
|
-
_a.sent();
|
|
100
|
-
return [2 /*return*/, x];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}); });
|
|
83
|
+
return dp.delete(id).then(function (x) {
|
|
84
|
+
save();
|
|
85
|
+
return x;
|
|
86
|
+
});
|
|
104
87
|
});
|
|
105
88
|
}));
|
|
106
89
|
};
|
|
@@ -110,16 +93,10 @@ var JsonEntityDataProvider = /** @class */ (function () {
|
|
|
110
93
|
return tslib_1.__generator(this, function (_a) {
|
|
111
94
|
return [2 /*return*/, (this.p = this.p.then(function () {
|
|
112
95
|
return _this.loadEntityData(function (dp, save) {
|
|
113
|
-
return dp.insert(data).then(function (x) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
case 1:
|
|
118
|
-
_a.sent();
|
|
119
|
-
return [2 /*return*/, x];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}); });
|
|
96
|
+
return dp.insert(data).then(function (x) {
|
|
97
|
+
save();
|
|
98
|
+
return x;
|
|
99
|
+
});
|
|
123
100
|
});
|
|
124
101
|
}))];
|
|
125
102
|
});
|
package/src/remult3/Fields.d.ts
CHANGED
|
@@ -54,26 +54,6 @@ export declare class Relations {
|
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
57
|
-
/**
|
|
58
|
-
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
59
|
-
* This overload allows you to define the relation using options.
|
|
60
|
-
* If no field or fields are provided, it will automatically create a field in the database
|
|
61
|
-
* to represent the relation.
|
|
62
|
-
*
|
|
63
|
-
* @param toEntityType A function that returns the target entity type.
|
|
64
|
-
* @param options An object containing options for configuring the to-one relation.
|
|
65
|
-
* - field (Optional): The name of the field in the related entity that corresponds to this relation.
|
|
66
|
-
* @returns A decorator function to apply the virtual to-one relation to an entity field.
|
|
67
|
-
*
|
|
68
|
-
* Example usage:
|
|
69
|
-
* ```
|
|
70
|
-
* @Relations.toOne(() => Customer, {
|
|
71
|
-
* field: "customerId",
|
|
72
|
-
* })
|
|
73
|
-
* customer?: Customer;
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
77
57
|
/**
|
|
78
58
|
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
79
59
|
* If no field or fields are provided, it will automatically create a field in the database
|
package/src/remult3/remult3.js
CHANGED