remult 0.26.23-next.1 → 0.26.23-next.2
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/src/filter/filter-interfaces.js +1 -1
- package/esm/src/remult3/RepositoryImplementation.js +32 -24
- package/package.json +1 -1
- package/src/CompoundIdField.d.ts +1 -1
- package/src/filter/filter-interfaces.d.ts +1 -0
- package/src/filter/filter-interfaces.js +0 -1
- package/src/remult3/RepositoryImplementation.d.ts +5 -2
- package/src/remult3/RepositoryImplementation.js +39 -23
- package/src/remult3/remult3.d.ts +2 -2
|
@@ -285,8 +285,8 @@ export class Filter {
|
|
|
285
285
|
this.__applyToConsumer(r);
|
|
286
286
|
return r.result;
|
|
287
287
|
}
|
|
288
|
-
//@internal
|
|
289
288
|
static async translateCustomWhere(r, entity, remult) {
|
|
289
|
+
// Used in hagai
|
|
290
290
|
let f = new customTranslator(async (filterKey, custom) => {
|
|
291
291
|
let r = [];
|
|
292
292
|
for (const key in entity.entityType) {
|
|
@@ -1161,15 +1161,16 @@ class rowHelperBase {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
export class rowHelperImplementation extends rowHelperBase {
|
|
1163
1163
|
info;
|
|
1164
|
-
|
|
1164
|
+
repo;
|
|
1165
1165
|
edp;
|
|
1166
1166
|
_isNew;
|
|
1167
|
-
constructor(info, instance,
|
|
1167
|
+
constructor(info, instance, repo, edp, remult, _isNew) {
|
|
1168
1168
|
super(info.fieldsMetadata, instance, remult, _isNew);
|
|
1169
1169
|
this.info = info;
|
|
1170
|
-
this.
|
|
1170
|
+
this.repo = repo;
|
|
1171
1171
|
this.edp = edp;
|
|
1172
1172
|
this._isNew = _isNew;
|
|
1173
|
+
this.repository = repo;
|
|
1173
1174
|
this.metadata = info;
|
|
1174
1175
|
if (_isNew) {
|
|
1175
1176
|
for (const col of info.fieldsMetadata) {
|
|
@@ -1188,12 +1189,13 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1188
1189
|
if (Remult.entityRefInit)
|
|
1189
1190
|
Remult.entityRefInit(this, instance);
|
|
1190
1191
|
}
|
|
1192
|
+
repository;
|
|
1191
1193
|
clone() {
|
|
1192
1194
|
const data = this.toApiJson(true, true);
|
|
1193
|
-
return this.
|
|
1195
|
+
return this.repo.fromJson(data, this.isNew());
|
|
1194
1196
|
}
|
|
1195
1197
|
get relations() {
|
|
1196
|
-
return this.
|
|
1198
|
+
return this.repo.relations(this.instance);
|
|
1197
1199
|
}
|
|
1198
1200
|
get apiUpdateAllowed() {
|
|
1199
1201
|
return this.remult.isAllowedForInstance(this.instance, this.metadata.options.allowApiUpdate);
|
|
@@ -1233,7 +1235,7 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1233
1235
|
.find({ where: await this.getIdFilter() })
|
|
1234
1236
|
.then(async (newData) => {
|
|
1235
1237
|
if (newData.length === 0)
|
|
1236
|
-
throw this.
|
|
1238
|
+
throw this.repo._notFoundError(this.id);
|
|
1237
1239
|
await this.loadDataFrom(newData[0]);
|
|
1238
1240
|
this.saveOriginalData();
|
|
1239
1241
|
});
|
|
@@ -1276,7 +1278,7 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1276
1278
|
await this.__validateEntity();
|
|
1277
1279
|
let doNotSave = false;
|
|
1278
1280
|
let e = this.buildLifeCycleEvent(() => (doNotSave = true));
|
|
1279
|
-
if (!this.
|
|
1281
|
+
if (!this.repo._dataProvider.isProxy) {
|
|
1280
1282
|
for (const col of this.fields) {
|
|
1281
1283
|
if (col.metadata.options.saving)
|
|
1282
1284
|
await col.metadata.options.saving(this.instance, col, e);
|
|
@@ -1338,15 +1340,15 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1338
1340
|
if (updatedRow)
|
|
1339
1341
|
await this.loadDataFrom(updatedRow);
|
|
1340
1342
|
e.id = this.getId();
|
|
1341
|
-
if (!this.
|
|
1343
|
+
if (!this.repo._dataProvider.isProxy) {
|
|
1342
1344
|
if (this.info.entityInfo.saved)
|
|
1343
1345
|
await this.info.entityInfo.saved(this.instance, e);
|
|
1344
|
-
if (this.
|
|
1345
|
-
for (const listener of this.
|
|
1346
|
+
if (this.repo.listeners)
|
|
1347
|
+
for (const listener of this.repo.listeners) {
|
|
1346
1348
|
await listener.saved?.(this.instance, isNew);
|
|
1347
1349
|
}
|
|
1348
1350
|
}
|
|
1349
|
-
await this.
|
|
1351
|
+
await this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }]);
|
|
1350
1352
|
this.saveOriginalData();
|
|
1351
1353
|
this._isNew = false;
|
|
1352
1354
|
return this.instance;
|
|
@@ -1389,20 +1391,20 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1389
1391
|
fields: self.fields,
|
|
1390
1392
|
id: self.getId(),
|
|
1391
1393
|
originalId: self.getOriginalId(),
|
|
1392
|
-
metadata: self.
|
|
1393
|
-
repository: self.
|
|
1394
|
+
metadata: self.repo.metadata,
|
|
1395
|
+
repository: self.repo,
|
|
1394
1396
|
preventDefault: () => preventDefault(),
|
|
1395
|
-
relations: self.
|
|
1397
|
+
relations: self.repo.relations(self.instance),
|
|
1396
1398
|
};
|
|
1397
1399
|
}
|
|
1398
1400
|
async getIdFilter() {
|
|
1399
|
-
return await this.
|
|
1401
|
+
return await this.repo._translateWhereToFilter(this.repo.metadata.idMetadata.getIdFilter(this.id));
|
|
1400
1402
|
}
|
|
1401
1403
|
async delete() {
|
|
1402
1404
|
this.__clearErrorsAndReportChanged();
|
|
1403
1405
|
let doDelete = true;
|
|
1404
1406
|
let e = this.buildLifeCycleEvent(() => (doDelete = false));
|
|
1405
|
-
if (!this.
|
|
1407
|
+
if (!this.repo._dataProvider.isProxy) {
|
|
1406
1408
|
if (this.info.entityInfo.deleting)
|
|
1407
1409
|
await this.info.entityInfo.deleting(this.instance, e);
|
|
1408
1410
|
}
|
|
@@ -1410,15 +1412,15 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1410
1412
|
try {
|
|
1411
1413
|
if (doDelete)
|
|
1412
1414
|
await this.edp.delete(this.id);
|
|
1413
|
-
if (!this.
|
|
1415
|
+
if (!this.repo._dataProvider.isProxy) {
|
|
1414
1416
|
if (this.info.entityInfo.deleted)
|
|
1415
1417
|
await this.info.entityInfo.deleted(this.instance, e);
|
|
1416
1418
|
}
|
|
1417
|
-
if (this.
|
|
1418
|
-
for (const listener of this.
|
|
1419
|
+
if (this.repo.listeners)
|
|
1420
|
+
for (const listener of this.repo.listeners) {
|
|
1419
1421
|
await listener.deleted?.(this.instance);
|
|
1420
1422
|
}
|
|
1421
|
-
await this.
|
|
1423
|
+
await this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: true }]);
|
|
1422
1424
|
this._wasDeleted = true;
|
|
1423
1425
|
}
|
|
1424
1426
|
catch (err) {
|
|
@@ -1485,8 +1487,8 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1485
1487
|
let e = this.buildLifeCycleEvent(() => { });
|
|
1486
1488
|
await this.info.entityInfo.validation(this.instance, e);
|
|
1487
1489
|
}
|
|
1488
|
-
if (this.
|
|
1489
|
-
for (const listener of this.
|
|
1490
|
+
if (this.repo.listeners)
|
|
1491
|
+
for (const listener of this.repo.listeners) {
|
|
1490
1492
|
await listener.validating?.(this.instance);
|
|
1491
1493
|
}
|
|
1492
1494
|
}
|
|
@@ -1581,15 +1583,21 @@ export class FieldRefImplementation {
|
|
|
1581
1583
|
let lu = this.rowBase.lookups.get(this.metadata.key);
|
|
1582
1584
|
return this.rawOriginalValue() === null;
|
|
1583
1585
|
}
|
|
1586
|
+
get key() {
|
|
1587
|
+
return this.metadata.key;
|
|
1588
|
+
}
|
|
1589
|
+
get repo() {
|
|
1590
|
+
return this.helper?.repository;
|
|
1591
|
+
}
|
|
1584
1592
|
async load() {
|
|
1585
1593
|
let lu = this.rowBase.lookups.get(this.metadata.key);
|
|
1586
1594
|
let rel = getRelationFieldInfo(this.metadata);
|
|
1587
1595
|
if (rel && this.helper) {
|
|
1588
1596
|
if (rel.type === 'toMany') {
|
|
1589
|
-
return (this.container[this.metadata.key] = await this.
|
|
1597
|
+
return (this.container[this.metadata.key] = await this.repo.relations(this.container)[this.key].find());
|
|
1590
1598
|
}
|
|
1591
1599
|
else {
|
|
1592
|
-
let val = await this.
|
|
1600
|
+
let val = await this.repo
|
|
1593
1601
|
.relations(this.container)[this.metadata.key].findOne();
|
|
1594
1602
|
if (val)
|
|
1595
1603
|
this.container[this.metadata.key] = val;
|
package/package.json
CHANGED
package/src/CompoundIdField.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class CompoundIdField implements FieldMetadata<string> {
|
|
|
11
11
|
fromInput(inputValue: string, inputType?: string): string;
|
|
12
12
|
getDbName(): Promise<string>;
|
|
13
13
|
getId(instance: any): string;
|
|
14
|
-
options: FieldOptions
|
|
14
|
+
options: FieldOptions;
|
|
15
15
|
get valueConverter(): Required<ValueConverter<string>>;
|
|
16
16
|
target: ClassType<any>;
|
|
17
17
|
readonly: boolean;
|
|
@@ -182,6 +182,7 @@ export declare class Filter {
|
|
|
182
182
|
*/
|
|
183
183
|
static resolve<entityType>(filter: EntityFilter<entityType> | (() => EntityFilter<entityType> | Promise<EntityFilter<entityType>>)): Promise<EntityFilter<entityType>>;
|
|
184
184
|
toJson(): any;
|
|
185
|
+
static translateCustomWhere<T>(r: Filter, entity: EntityMetadata<T>, remult: Remult): Promise<Filter>;
|
|
185
186
|
}
|
|
186
187
|
export interface FilterConsumer {
|
|
187
188
|
or(orElements: Filter[]): void;
|
|
@@ -349,7 +349,6 @@ var Filter = /** @class */ (function () {
|
|
|
349
349
|
this.__applyToConsumer(r);
|
|
350
350
|
return r.result;
|
|
351
351
|
};
|
|
352
|
-
//@internal
|
|
353
352
|
Filter.translateCustomWhere = function (r, entity, remult) {
|
|
354
353
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
355
354
|
var f;
|
|
@@ -121,10 +121,11 @@ declare abstract class rowHelperBase<T> {
|
|
|
121
121
|
}
|
|
122
122
|
export declare class rowHelperImplementation<T> extends rowHelperBase<T> implements EntityRef<T> {
|
|
123
123
|
private info;
|
|
124
|
-
|
|
124
|
+
private repo;
|
|
125
125
|
private edp;
|
|
126
126
|
private _isNew;
|
|
127
|
-
constructor(info: EntityFullInfo<T>, instance: T,
|
|
127
|
+
constructor(info: EntityFullInfo<T>, instance: T, repo: RepositoryImplementation<T>, edp: EntityDataProvider, remult: Remult, _isNew: boolean);
|
|
128
|
+
repository: Repository<unknown>;
|
|
128
129
|
clone(): T;
|
|
129
130
|
get relations(): RepositoryRelations<T>;
|
|
130
131
|
get apiUpdateAllowed(): boolean;
|
|
@@ -173,6 +174,8 @@ export declare class FieldRefImplementation<entityType, valueType> implements Fi
|
|
|
173
174
|
subscribe(listener: RefSubscriber): Unsubscribe;
|
|
174
175
|
valueIsNull(): boolean;
|
|
175
176
|
originalValueIsNull(): boolean;
|
|
177
|
+
get key(): keyof entityType;
|
|
178
|
+
get repo(): Repository<entityType>;
|
|
176
179
|
load(): Promise<valueType>;
|
|
177
180
|
target?: ClassType<any>;
|
|
178
181
|
reportObserved(): void;
|
|
@@ -1925,15 +1925,16 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1925
1925
|
}());
|
|
1926
1926
|
var rowHelperImplementation = /** @class */ (function (_super) {
|
|
1927
1927
|
tslib_1.__extends(rowHelperImplementation, _super);
|
|
1928
|
-
function rowHelperImplementation(info, instance,
|
|
1928
|
+
function rowHelperImplementation(info, instance, repo, edp, remult, _isNew) {
|
|
1929
1929
|
var e_30, _a;
|
|
1930
1930
|
var _this = _super.call(this, info.fieldsMetadata, instance, remult, _isNew) || this;
|
|
1931
1931
|
_this.info = info;
|
|
1932
|
-
_this.
|
|
1932
|
+
_this.repo = repo;
|
|
1933
1933
|
_this.edp = edp;
|
|
1934
1934
|
_this._isNew = _isNew;
|
|
1935
1935
|
_this._wasDeleted = false;
|
|
1936
1936
|
_this._saving = false;
|
|
1937
|
+
_this.repository = repo;
|
|
1937
1938
|
_this.metadata = info;
|
|
1938
1939
|
if (_isNew) {
|
|
1939
1940
|
try {
|
|
@@ -1965,11 +1966,11 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1965
1966
|
}
|
|
1966
1967
|
rowHelperImplementation.prototype.clone = function () {
|
|
1967
1968
|
var data = this.toApiJson(true, true);
|
|
1968
|
-
return this.
|
|
1969
|
+
return this.repo.fromJson(data, this.isNew());
|
|
1969
1970
|
};
|
|
1970
1971
|
Object.defineProperty(rowHelperImplementation.prototype, "relations", {
|
|
1971
1972
|
get: function () {
|
|
1972
|
-
return this.
|
|
1973
|
+
return this.repo.relations(this.instance);
|
|
1973
1974
|
},
|
|
1974
1975
|
enumerable: false,
|
|
1975
1976
|
configurable: true
|
|
@@ -2037,7 +2038,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2037
2038
|
switch (_a.label) {
|
|
2038
2039
|
case 0:
|
|
2039
2040
|
if (newData.length === 0)
|
|
2040
|
-
throw this.
|
|
2041
|
+
throw this.repo._notFoundError(this.id);
|
|
2041
2042
|
return [4 /*yield*/, this.loadDataFrom(newData[0])];
|
|
2042
2043
|
case 1:
|
|
2043
2044
|
_a.sent();
|
|
@@ -2117,7 +2118,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2117
2118
|
case 2:
|
|
2118
2119
|
doNotSave_1 = false;
|
|
2119
2120
|
e = this.buildLifeCycleEvent(function () { return (doNotSave_1 = true); });
|
|
2120
|
-
if (!!this.
|
|
2121
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 12];
|
|
2121
2122
|
_t.label = 3;
|
|
2122
2123
|
case 3:
|
|
2123
2124
|
_t.trys.push([3, 8, 9, 10]);
|
|
@@ -2232,18 +2233,18 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2232
2233
|
_t.label = 26;
|
|
2233
2234
|
case 26:
|
|
2234
2235
|
e.id = this.getId();
|
|
2235
|
-
if (!!this.
|
|
2236
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 36];
|
|
2236
2237
|
if (!this.info.entityInfo.saved) return [3 /*break*/, 28];
|
|
2237
2238
|
return [4 /*yield*/, this.info.entityInfo.saved(this.instance, e)];
|
|
2238
2239
|
case 27:
|
|
2239
2240
|
_t.sent();
|
|
2240
2241
|
_t.label = 28;
|
|
2241
2242
|
case 28:
|
|
2242
|
-
if (!this.
|
|
2243
|
+
if (!this.repo.listeners) return [3 /*break*/, 36];
|
|
2243
2244
|
_t.label = 29;
|
|
2244
2245
|
case 29:
|
|
2245
2246
|
_t.trys.push([29, 34, 35, 36]);
|
|
2246
|
-
_j = tslib_1.__values(this.
|
|
2247
|
+
_j = tslib_1.__values(this.repo.listeners), _k = _j.next();
|
|
2247
2248
|
_t.label = 30;
|
|
2248
2249
|
case 30:
|
|
2249
2250
|
if (!!_k.done) return [3 /*break*/, 33];
|
|
@@ -2266,7 +2267,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2266
2267
|
}
|
|
2267
2268
|
finally { if (e_33) throw e_33.error; }
|
|
2268
2269
|
return [7 /*endfinally*/];
|
|
2269
|
-
case 36: return [4 /*yield*/, this.
|
|
2270
|
+
case 36: return [4 /*yield*/, this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: false }])];
|
|
2270
2271
|
case 37:
|
|
2271
2272
|
_t.sent();
|
|
2272
2273
|
this.saveOriginalData();
|
|
@@ -2344,17 +2345,17 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2344
2345
|
fields: self.fields,
|
|
2345
2346
|
id: self.getId(),
|
|
2346
2347
|
originalId: self.getOriginalId(),
|
|
2347
|
-
metadata: self.
|
|
2348
|
-
repository: self.
|
|
2348
|
+
metadata: self.repo.metadata,
|
|
2349
|
+
repository: self.repo,
|
|
2349
2350
|
preventDefault: function () { return preventDefault(); },
|
|
2350
|
-
relations: self.
|
|
2351
|
+
relations: self.repo.relations(self.instance),
|
|
2351
2352
|
};
|
|
2352
2353
|
};
|
|
2353
2354
|
rowHelperImplementation.prototype.getIdFilter = function () {
|
|
2354
2355
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2355
2356
|
return tslib_1.__generator(this, function (_a) {
|
|
2356
2357
|
switch (_a.label) {
|
|
2357
|
-
case 0: return [4 /*yield*/, this.
|
|
2358
|
+
case 0: return [4 /*yield*/, this.repo._translateWhereToFilter(this.repo.metadata.idMetadata.getIdFilter(this.id))];
|
|
2358
2359
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2359
2360
|
}
|
|
2360
2361
|
});
|
|
@@ -2371,7 +2372,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2371
2372
|
this.__clearErrorsAndReportChanged();
|
|
2372
2373
|
doDelete = true;
|
|
2373
2374
|
e = this.buildLifeCycleEvent(function () { return (doDelete = false); });
|
|
2374
|
-
if (!!this.
|
|
2375
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 2];
|
|
2375
2376
|
if (!this.info.entityInfo.deleting) return [3 /*break*/, 2];
|
|
2376
2377
|
return [4 /*yield*/, this.info.entityInfo.deleting(this.instance, e)];
|
|
2377
2378
|
case 1:
|
|
@@ -2388,18 +2389,18 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2388
2389
|
_e.sent();
|
|
2389
2390
|
_e.label = 5;
|
|
2390
2391
|
case 5:
|
|
2391
|
-
if (!!this.
|
|
2392
|
+
if (!!this.repo._dataProvider.isProxy) return [3 /*break*/, 7];
|
|
2392
2393
|
if (!this.info.entityInfo.deleted) return [3 /*break*/, 7];
|
|
2393
2394
|
return [4 /*yield*/, this.info.entityInfo.deleted(this.instance, e)];
|
|
2394
2395
|
case 6:
|
|
2395
2396
|
_e.sent();
|
|
2396
2397
|
_e.label = 7;
|
|
2397
2398
|
case 7:
|
|
2398
|
-
if (!this.
|
|
2399
|
+
if (!this.repo.listeners) return [3 /*break*/, 15];
|
|
2399
2400
|
_e.label = 8;
|
|
2400
2401
|
case 8:
|
|
2401
2402
|
_e.trys.push([8, 13, 14, 15]);
|
|
2402
|
-
_a = tslib_1.__values(this.
|
|
2403
|
+
_a = tslib_1.__values(this.repo.listeners), _b = _a.next();
|
|
2403
2404
|
_e.label = 9;
|
|
2404
2405
|
case 9:
|
|
2405
2406
|
if (!!_b.done) return [3 /*break*/, 12];
|
|
@@ -2422,7 +2423,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2422
2423
|
}
|
|
2423
2424
|
finally { if (e_36) throw e_36.error; }
|
|
2424
2425
|
return [7 /*endfinally*/];
|
|
2425
|
-
case 15: return [4 /*yield*/, this.
|
|
2426
|
+
case 15: return [4 /*yield*/, this.repo._remult.liveQueryPublisher.itemChanged(this.repo.metadata.key, [{ id: this.getId(), oldId: this.getOriginalId(), deleted: true }])];
|
|
2426
2427
|
case 16:
|
|
2427
2428
|
_e.sent();
|
|
2428
2429
|
this._wasDeleted = true;
|
|
@@ -2608,11 +2609,11 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2608
2609
|
_h.sent();
|
|
2609
2610
|
_h.label = 9;
|
|
2610
2611
|
case 9:
|
|
2611
|
-
if (!this.
|
|
2612
|
+
if (!this.repo.listeners) return [3 /*break*/, 17];
|
|
2612
2613
|
_h.label = 10;
|
|
2613
2614
|
case 10:
|
|
2614
2615
|
_h.trys.push([10, 15, 16, 17]);
|
|
2615
|
-
_c = tslib_1.__values(this.
|
|
2616
|
+
_c = tslib_1.__values(this.repo.listeners), _d = _c.next();
|
|
2616
2617
|
_h.label = 11;
|
|
2617
2618
|
case 11:
|
|
2618
2619
|
if (!!_d.done) return [3 /*break*/, 14];
|
|
@@ -2776,6 +2777,21 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2776
2777
|
var lu = this.rowBase.lookups.get(this.metadata.key);
|
|
2777
2778
|
return this.rawOriginalValue() === null;
|
|
2778
2779
|
};
|
|
2780
|
+
Object.defineProperty(FieldRefImplementation.prototype, "key", {
|
|
2781
|
+
get: function () {
|
|
2782
|
+
return this.metadata.key;
|
|
2783
|
+
},
|
|
2784
|
+
enumerable: false,
|
|
2785
|
+
configurable: true
|
|
2786
|
+
});
|
|
2787
|
+
Object.defineProperty(FieldRefImplementation.prototype, "repo", {
|
|
2788
|
+
get: function () {
|
|
2789
|
+
var _a;
|
|
2790
|
+
return (_a = this.helper) === null || _a === void 0 ? void 0 : _a.repository;
|
|
2791
|
+
},
|
|
2792
|
+
enumerable: false,
|
|
2793
|
+
configurable: true
|
|
2794
|
+
});
|
|
2779
2795
|
FieldRefImplementation.prototype.load = function () {
|
|
2780
2796
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2781
2797
|
var lu, rel, _a, _b, val;
|
|
@@ -2788,9 +2804,9 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2788
2804
|
if (!(rel.type === 'toMany')) return [3 /*break*/, 2];
|
|
2789
2805
|
_a = this.container;
|
|
2790
2806
|
_b = this.metadata.key;
|
|
2791
|
-
return [4 /*yield*/, this.
|
|
2807
|
+
return [4 /*yield*/, this.repo.relations(this.container)[this.key].find()];
|
|
2792
2808
|
case 1: return [2 /*return*/, (_a[_b] = _c.sent())];
|
|
2793
|
-
case 2: return [4 /*yield*/, this.
|
|
2809
|
+
case 2: return [4 /*yield*/, this.repo
|
|
2794
2810
|
.relations(this.container)[this.metadata.key].findOne()];
|
|
2795
2811
|
case 3:
|
|
2796
2812
|
val = _c.sent();
|
package/src/remult3/remult3.d.ts
CHANGED
|
@@ -18,8 +18,8 @@ export interface EntityRefBase<entityType> extends Subscribable {
|
|
|
18
18
|
error: string | undefined;
|
|
19
19
|
getId(): idType<entityType>;
|
|
20
20
|
getOriginalId(): idType<entityType>;
|
|
21
|
-
repository: Repository<
|
|
22
|
-
metadata: EntityMetadata<
|
|
21
|
+
repository: Repository<unknown>;
|
|
22
|
+
metadata: EntityMetadata<unknown>;
|
|
23
23
|
toApiJson(): any;
|
|
24
24
|
validate(): Promise<ErrorInfo<entityType> | undefined>;
|
|
25
25
|
readonly apiUpdateAllowed: boolean;
|