remult 0.18.1-exp.39 → 0.18.1-exp.40
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/remult-proxy.js +1 -0
- package/esm/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/esm/src/remult3/RepositoryImplementation.js +8 -3
- package/package.json +1 -1
- package/src/remult-proxy.js +4 -0
- package/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/src/remult3/RepositoryImplementation.js +9 -3
package/esm/src/remult-proxy.js
CHANGED
|
@@ -18,6 +18,7 @@ export class RemultProxy {
|
|
|
18
18
|
getEntityRef: (...args2) => self.remultFactory().repo(...args).getEntityRef(...args2),
|
|
19
19
|
insert: (args2) => self.remultFactory().repo(...args).insert(args2),
|
|
20
20
|
liveQuery: (...args2) => self.remultFactory().repo(...args).liveQuery(...args2),
|
|
21
|
+
addToCache: (args2) => self.remultFactory().repo(...args).addToCache(args2),
|
|
21
22
|
get metadata() {
|
|
22
23
|
return self.remultFactory().repo(...args).metadata;
|
|
23
24
|
},
|
|
@@ -42,7 +42,7 @@ export declare class RepositoryImplementation<entityType> implements Repository<
|
|
|
42
42
|
save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
|
|
43
43
|
save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
44
44
|
liveQuery(options?: FindOptions<entityType>): any;
|
|
45
|
-
find(options: FindOptions<entityType
|
|
45
|
+
find(options: FindOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType[]>;
|
|
46
46
|
buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
|
|
47
47
|
fromJsonArray(jsonItems: any[], load?: (entity: FieldsMetadata<entityType>) => FieldMetadata[]): Promise<entityType[]>;
|
|
48
48
|
private loadManyToOneForManyRows;
|
|
@@ -101,6 +101,7 @@ export class RepositoryImplementation {
|
|
|
101
101
|
this.idCache.set(id, row);
|
|
102
102
|
return await row;
|
|
103
103
|
}
|
|
104
|
+
//TODO - Used to prevent unnecessary many to one relations
|
|
104
105
|
addToCache(item) {
|
|
105
106
|
if (item)
|
|
106
107
|
this.idCache.set(this.getEntityRef(item).getId() + '', item);
|
|
@@ -219,11 +220,15 @@ export class RepositoryImplementation {
|
|
|
219
220
|
}
|
|
220
221
|
};
|
|
221
222
|
}
|
|
222
|
-
async find(options) {
|
|
223
|
+
async find(options, skipOrderByAndLimit = false) {
|
|
223
224
|
Remult.onFind(this._info, options);
|
|
224
225
|
if (!options)
|
|
225
226
|
options = {};
|
|
226
227
|
let opt = await this.buildEntityDataProviderFindOptions(options);
|
|
228
|
+
if (skipOrderByAndLimit) {
|
|
229
|
+
delete opt.orderBy;
|
|
230
|
+
delete opt.limit;
|
|
231
|
+
}
|
|
227
232
|
let rawRows = await this.edp.find(opt);
|
|
228
233
|
let result = await this.loadManyToOneForManyRows(rawRows, options.load);
|
|
229
234
|
return result;
|
|
@@ -275,7 +280,7 @@ export class RepositoryImplementation {
|
|
|
275
280
|
}
|
|
276
281
|
}
|
|
277
282
|
async function loadManyToOne(repo, toLoad) {
|
|
278
|
-
let rows = await repo.find({ where: repo.metadata.idMetadata.getIdFilter(...toLoad) });
|
|
283
|
+
let rows = await repo.find({ where: repo.metadata.idMetadata.getIdFilter(...toLoad) }, true);
|
|
279
284
|
for (const r of rows) {
|
|
280
285
|
repo.addToCache(r);
|
|
281
286
|
}
|
|
@@ -353,7 +358,7 @@ export class RepositoryImplementation {
|
|
|
353
358
|
this.cache.set(key, cacheInfo);
|
|
354
359
|
}
|
|
355
360
|
}
|
|
356
|
-
r = this.find(
|
|
361
|
+
r = this.find({ ...options, limit: 1 }, skipOrderByAndLimit).then(async (items) => {
|
|
357
362
|
let r = undefined;
|
|
358
363
|
if (items.length > 0)
|
|
359
364
|
r = items[0];
|
package/package.json
CHANGED
package/src/remult-proxy.js
CHANGED
|
@@ -96,6 +96,10 @@ var RemultProxy = /** @class */ (function () {
|
|
|
96
96
|
}
|
|
97
97
|
return (_a = (_b = self.remultFactory()).repo.apply(_b, tslib_1.__spread(args))).liveQuery.apply(_a, tslib_1.__spread(args2));
|
|
98
98
|
},
|
|
99
|
+
addToCache: function (args2) {
|
|
100
|
+
var _a;
|
|
101
|
+
return (_a = self.remultFactory()).repo.apply(_a, tslib_1.__spread(args)).addToCache(args2);
|
|
102
|
+
},
|
|
99
103
|
get metadata() {
|
|
100
104
|
var _a;
|
|
101
105
|
return (_a = self.remultFactory()).repo.apply(_a, tslib_1.__spread(args)).metadata;
|
|
@@ -42,7 +42,7 @@ export declare class RepositoryImplementation<entityType> implements Repository<
|
|
|
42
42
|
save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
|
|
43
43
|
save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
44
44
|
liveQuery(options?: FindOptions<entityType>): any;
|
|
45
|
-
find(options: FindOptions<entityType
|
|
45
|
+
find(options: FindOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType[]>;
|
|
46
46
|
buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
|
|
47
47
|
fromJsonArray(jsonItems: any[], load?: (entity: FieldsMetadata<entityType>) => FieldMetadata[]): Promise<entityType[]>;
|
|
48
48
|
private loadManyToOneForManyRows;
|
|
@@ -157,6 +157,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
157
157
|
});
|
|
158
158
|
});
|
|
159
159
|
};
|
|
160
|
+
//TODO - Used to prevent unnecessary many to one relations
|
|
160
161
|
RepositoryImplementation.prototype.addToCache = function (item) {
|
|
161
162
|
if (item)
|
|
162
163
|
this.idCache.set(this.getEntityRef(item).getId() + '', item);
|
|
@@ -345,7 +346,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
345
346
|
}
|
|
346
347
|
};
|
|
347
348
|
};
|
|
348
|
-
RepositoryImplementation.prototype.find = function (options) {
|
|
349
|
+
RepositoryImplementation.prototype.find = function (options, skipOrderByAndLimit) {
|
|
350
|
+
if (skipOrderByAndLimit === void 0) { skipOrderByAndLimit = false; }
|
|
349
351
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
350
352
|
var opt, rawRows, result;
|
|
351
353
|
return tslib_1.__generator(this, function (_a) {
|
|
@@ -357,6 +359,10 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
357
359
|
return [4 /*yield*/, this.buildEntityDataProviderFindOptions(options)];
|
|
358
360
|
case 1:
|
|
359
361
|
opt = _a.sent();
|
|
362
|
+
if (skipOrderByAndLimit) {
|
|
363
|
+
delete opt.orderBy;
|
|
364
|
+
delete opt.limit;
|
|
365
|
+
}
|
|
360
366
|
return [4 /*yield*/, this.edp.find(opt)];
|
|
361
367
|
case 2:
|
|
362
368
|
rawRows = _a.sent();
|
|
@@ -424,7 +430,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
424
430
|
var _a, e_9, _b;
|
|
425
431
|
return tslib_1.__generator(this, function (_c) {
|
|
426
432
|
switch (_c.label) {
|
|
427
|
-
case 0: return [4 /*yield*/, repo.find({ where: (_a = repo.metadata.idMetadata).getIdFilter.apply(_a, tslib_1.__spread(toLoad)) })];
|
|
433
|
+
case 0: return [4 /*yield*/, repo.find({ where: (_a = repo.metadata.idMetadata).getIdFilter.apply(_a, tslib_1.__spread(toLoad)) }, true)];
|
|
428
434
|
case 1:
|
|
429
435
|
rows = _c.sent();
|
|
430
436
|
try {
|
|
@@ -635,7 +641,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
635
641
|
}
|
|
636
642
|
_a.label = 2;
|
|
637
643
|
case 2:
|
|
638
|
-
r = this.find(
|
|
644
|
+
r = this.find(tslib_1.__assign(tslib_1.__assign({}, options), { limit: 1 }), skipOrderByAndLimit).then(function (items) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
639
645
|
var r;
|
|
640
646
|
return tslib_1.__generator(this, function (_a) {
|
|
641
647
|
switch (_a.label) {
|