remult 0.22.9-exp.0 → 0.23.0-exp.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.
@@ -86,6 +86,7 @@ class KnexEntityDataProvider {
86
86
  return +element;
87
87
  }
88
88
  }
89
+ throw Error("couldn't find count member");
89
90
  }
90
91
  async find(options) {
91
92
  const e = await this.init();
@@ -4,7 +4,7 @@ import type { RepositoryOverloads } from './src/remult3/RepositoryImplementation
4
4
  export declare class MongoDataProvider implements DataProvider {
5
5
  private db;
6
6
  private client;
7
- constructor(db: Db, client: MongoClient, options?: {
7
+ constructor(db: Db, client: MongoClient | undefined, options?: {
8
8
  session?: ClientSession;
9
9
  disableTransactions?: boolean;
10
10
  });
@@ -10,7 +10,7 @@ export class MongoDataProvider {
10
10
  this.db = db;
11
11
  this.client = client;
12
12
  this.session = options?.session;
13
- this.disableTransactions = options?.disableTransactions;
13
+ this.disableTransactions = Boolean(options?.disableTransactions);
14
14
  }
15
15
  session;
16
16
  disableTransactions = false;
@@ -28,6 +28,8 @@ export class MongoDataProvider {
28
28
  await action(this);
29
29
  }
30
30
  else {
31
+ if (!this.client)
32
+ throw new Error("Can't use transactions within transactions");
31
33
  let session = await this.client.startSession();
32
34
  session.startTransaction();
33
35
  const db = this.client.db(this.db.databaseName);
@@ -198,7 +200,7 @@ class FilterConsumerBridgeToMongo {
198
200
  f._addWhere = false;
199
201
  element.__applyToConsumer(f);
200
202
  let where = await f.resolveWhere();
201
- if (where?.$and?.length > 0) {
203
+ if (where?.$and?.length) {
202
204
  result.push(where);
203
205
  }
204
206
  else
@@ -13,7 +13,7 @@ export class LiveQuerySubscriber {
13
13
  subscribeCode;
14
14
  unsubscribe = () => { };
15
15
  async setAllItems(result) {
16
- const items = await this.repo.fromJsonArray(result, this.query.options.load);
16
+ const items = await this.repo.fromJsonArray(result, this.query.options);
17
17
  this.forListeners((listener) => {
18
18
  listener((x) => {
19
19
  return items;
@@ -54,7 +54,7 @@ export class LiveQuerySubscriber {
54
54
  async handle(messages) {
55
55
  {
56
56
  let x = messages.filter(({ type }) => type == 'add' || type == 'replace');
57
- let loadedItems = await this.repo.fromJsonArray(x.map((m) => m.data.item), this.query.options.load);
57
+ let loadedItems = await this.repo.fromJsonArray(x.map((m) => m.data.item), this.query.options);
58
58
  for (let index = 0; index < x.length; index++) {
59
59
  const element = x[index];
60
60
  element.data.item = loadedItems[index];
@@ -3,7 +3,7 @@ import { LookupColumn } from '../column';
3
3
  import type { FieldMetadata, FieldOptions, ValueConverter, ValueListItem } from '../column-interfaces';
4
4
  import { Remult } from '../context';
5
5
  import type { EntityOptions } from '../entity';
6
- import type { ControllerRef, EntityFilter, EntityMetadata, EntityOrderBy, EntityRef, FieldRef, FieldsMetadata, FieldsRef, FindFirstOptions, FindFirstOptionsBase, FindOptions, IdMetadata, LiveQuery, OmitEB, QueryOptions, QueryResult, Repository, RepositoryRelations, Subscribable } from './remult3';
6
+ import type { ControllerRef, EntityFilter, EntityMetadata, EntityOrderBy, EntityRef, FieldRef, FieldsMetadata, FieldsRef, FindFirstOptions, FindFirstOptionsBase, FindOptions, IdMetadata, LiveQuery, LoadOptions, OmitEB, QueryOptions, QueryResult, Repository, RepositoryRelations, Subscribable } from './remult3';
7
7
  import type { RefSubscriber } from './remult3';
8
8
  import type { entityEventListener } from '../__EntityValueProvider';
9
9
  import type { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, ErrorInfo } from '../data-interfaces';
@@ -53,7 +53,7 @@ export declare class RepositoryImplementation<entityType> implements Repository<
53
53
  rawFind(options: FindOptions<entityType>, skipOrderByAndLimit: boolean, loader: RelationLoader): Promise<Awaited<entityType>[]>;
54
54
  find(options: FindOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType[]>;
55
55
  buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
56
- fromJsonArray(jsonItems: any[], load?: (entity: FieldsMetadata<entityType>) => FieldMetadata[]): Promise<Awaited<entityType>[]>;
56
+ fromJsonArray(jsonItems: any[], loadOptions: LoadOptions<entityType>): Promise<Awaited<entityType>[]>;
57
57
  private loadManyToOneForManyRows;
58
58
  private mapRawDataToResult;
59
59
  toJson(item: entityType | entityType[] | Promise<entityType> | Promise<entityType[]>): any;
@@ -80,7 +80,15 @@ export class RepositoryImplementation {
80
80
  throw Error(key + ' is not a relation');
81
81
  let repo = this.remult.repo(rel.toType());
82
82
  let { findOptions } = this.findOptionsBasedOnRelation(rel, field, undefined, item, repo);
83
- return new RepositoryImplementation(repo.entity, repo.remult, repo.dataProvider, repo._info, findOptions);
83
+ const toRepo = new RepositoryImplementation(repo.entity, repo.remult, repo.dataProvider, repo._info, findOptions);
84
+ if (rel.type === 'toMany')
85
+ return toRepo;
86
+ else
87
+ return {
88
+ findOne: (options) => {
89
+ return toRepo.findFirst({}, options);
90
+ },
91
+ };
84
92
  },
85
93
  });
86
94
  }
@@ -326,7 +334,7 @@ export class RepositoryImplementation {
326
334
  delete opt.limit;
327
335
  }
328
336
  const rawRows = await this.edp.find(opt);
329
- let result = await this.loadManyToOneForManyRows(rawRows, options.load, options.include, loader);
337
+ let result = await this.loadManyToOneForManyRows(rawRows, options, loader);
330
338
  return result;
331
339
  }
332
340
  async find(options, skipOrderByAndLimit = false) {
@@ -347,20 +355,22 @@ export class RepositoryImplementation {
347
355
  opt.page = options.page;
348
356
  return opt;
349
357
  }
350
- async fromJsonArray(jsonItems, load) {
358
+ async fromJsonArray(jsonItems, loadOptions) {
351
359
  const loader = new RelationLoader();
352
- return this.loadManyToOneForManyRows(jsonItems.map((row) => {
360
+ const result = await this.loadManyToOneForManyRows(jsonItems.map((row) => {
353
361
  let result = {};
354
362
  for (const col of this.metadata.fields.toArray()) {
355
363
  result[col.key] = col.valueConverter.fromJson(row[col.key]);
356
364
  }
357
365
  return result;
358
- }), load, undefined, loader);
366
+ }), loadOptions, loader);
367
+ await loader.resolveAll();
368
+ return result;
359
369
  }
360
- async loadManyToOneForManyRows(rawRows, load, include, loader) {
370
+ async loadManyToOneForManyRows(rawRows, loadOptions, loader) {
361
371
  let loadFields = undefined;
362
- if (load)
363
- loadFields = load(this.metadata.fields);
372
+ if (loadOptions?.load)
373
+ loadFields = loadOptions.load(this.metadata.fields);
364
374
  for (const col of this.metadata.fields) {
365
375
  let ei = getEntitySettings(col.valueType, false);
366
376
  if (ei) {
@@ -371,8 +381,8 @@ export class RepositoryImplementation {
371
381
  : !col.options.lazy;
372
382
  if (loadFields !== undefined)
373
383
  load = loadFields.includes(col);
374
- if (include)
375
- load = include[col.key];
384
+ if (loadOptions.include)
385
+ load = loadOptions.include[col.key];
376
386
  if (load) {
377
387
  let repo = this.remult.repo(col.valueType);
378
388
  let toLoad = [];
@@ -407,8 +417,8 @@ export class RepositoryImplementation {
407
417
  let rel = getRelationInfo(col.options);
408
418
  let incl = col.options
409
419
  .defaultIncluded;
410
- if (include) {
411
- incl = include?.[col.key];
420
+ if (loadOptions?.include) {
421
+ incl = loadOptions.include[col.key];
412
422
  }
413
423
  if (rel && incl) {
414
424
  const otherRepo = this.remult.repo(rel.toType());
@@ -1340,7 +1350,18 @@ export class FieldRefImplementation {
1340
1350
  }
1341
1351
  async load() {
1342
1352
  let lu = this.rowBase.lookups.get(this.metadata.key);
1343
- if (lu) {
1353
+ let rel = getRelationInfo(this.metadata.options);
1354
+ if (rel) {
1355
+ if (rel.type === 'toMany') {
1356
+ return (this.container[this.metadata.key] = await this.helper.repository
1357
+ .relations(this.container)[this.metadata.key].find());
1358
+ }
1359
+ else {
1360
+ return (this.container[this.metadata.key] = await this.helper.repository
1361
+ .relations(this.container)[this.metadata.key].findOne());
1362
+ }
1363
+ }
1364
+ else if (lu) {
1344
1365
  if (this.valueChanged()) {
1345
1366
  await lu.waitLoadOf(this.rawOriginalValue());
1346
1367
  }
@@ -414,7 +414,7 @@ export type RelationOptionsBase<fromEntity, toEntity, optionsType extends LoadOp
414
414
  } & FieldOptions<fromEntity, toEntity>;
415
415
  export type ObjectMembersOnly<T> = {
416
416
  [K in keyof Pick<T, {
417
- [K in keyof T]: T[K] extends object ? T[K] extends Date ? never : K : never;
417
+ [K in keyof T]: T[K] extends object | undefined | null ? T[K] extends Date | undefined | null ? never : K : never;
418
418
  }[keyof T]>]: T[K];
419
419
  };
420
420
  export type MembersToInclude<T> = {
@@ -1,5 +1 @@
1
1
  export {};
2
- //[ ] - implement find One
3
- //[ ] - for active record, implement waitLoad
4
- //[ ] - replace lookup Column with strategy for reference vs lazy
5
- //[ ] - test with live query
@@ -1,3 +1,3 @@
1
1
  import type { CompoundIdField } from './CompoundIdField';
2
2
  import { Filter } from './filter/filter-interfaces';
3
- export declare function resultCompoundIdFilter(idField: CompoundIdField, id: string, data: any): Filter;
3
+ export declare function resultCompoundIdFilter(idField: CompoundIdField, id: string | undefined, data: any): Filter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.22.9-exp.0",
3
+ "version": "0.23.0-exp.2",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "types": "index.d.ts",
6
6
  "module": "esm/index.js",
@@ -151,7 +151,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
151
151
  return [2 /*return*/, +element];
152
152
  }
153
153
  }
154
- return [2 /*return*/];
154
+ throw Error("couldn't find count member");
155
155
  }
156
156
  });
157
157
  });
package/remult-mongo.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { RepositoryOverloads } from './src/remult3/RepositoryImplementation
4
4
  export declare class MongoDataProvider implements DataProvider {
5
5
  private db;
6
6
  private client;
7
- constructor(db: Db, client: MongoClient, options?: {
7
+ constructor(db: Db, client: MongoClient | undefined, options?: {
8
8
  session?: ClientSession;
9
9
  disableTransactions?: boolean;
10
10
  });
package/remult-mongo.js CHANGED
@@ -13,7 +13,7 @@ var MongoDataProvider = /** @class */ (function () {
13
13
  this.client = client;
14
14
  this.disableTransactions = false;
15
15
  this.session = options === null || options === void 0 ? void 0 : options.session;
16
- this.disableTransactions = options === null || options === void 0 ? void 0 : options.disableTransactions;
16
+ this.disableTransactions = Boolean(options === null || options === void 0 ? void 0 : options.disableTransactions);
17
17
  }
18
18
  MongoDataProvider.getDb = function (remult) {
19
19
  var r = (remult || remult_proxy_1.remult).dataProvider;
@@ -35,7 +35,10 @@ var MongoDataProvider = /** @class */ (function () {
35
35
  case 1:
36
36
  _a.sent();
37
37
  return [3 /*break*/, 11];
38
- case 2: return [4 /*yield*/, this.client.startSession()];
38
+ case 2:
39
+ if (!this.client)
40
+ throw new Error("Can't use transactions within transactions");
41
+ return [4 /*yield*/, this.client.startSession()];
39
42
  case 3:
40
43
  session = _a.sent();
41
44
  session.startTransaction();
@@ -417,7 +420,7 @@ var FilterConsumerBridgeToMongo = /** @class */ (function () {
417
420
  return [4 /*yield*/, f.resolveWhere()];
418
421
  case 3:
419
422
  where = _c.sent();
420
- if (((_b = where === null || where === void 0 ? void 0 : where.$and) === null || _b === void 0 ? void 0 : _b.length) > 0) {
423
+ if ((_b = where === null || where === void 0 ? void 0 : where.$and) === null || _b === void 0 ? void 0 : _b.length) {
421
424
  result.push(where);
422
425
  }
423
426
  else
@@ -27,7 +27,7 @@ var LiveQuerySubscriber = /** @class */ (function () {
27
27
  var items;
28
28
  return tslib_1.__generator(this, function (_a) {
29
29
  switch (_a.label) {
30
- case 0: return [4 /*yield*/, this.repo.fromJsonArray(result, this.query.options.load)];
30
+ case 0: return [4 /*yield*/, this.repo.fromJsonArray(result, this.query.options)];
31
31
  case 1:
32
32
  items = _a.sent();
33
33
  this.forListeners(function (listener) {
@@ -97,7 +97,7 @@ var LiveQuerySubscriber = /** @class */ (function () {
97
97
  var type = _a.type;
98
98
  return type == 'add' || type == 'replace';
99
99
  });
100
- return [4 /*yield*/, this.repo.fromJsonArray(x.map(function (m) { return m.data.item; }), this.query.options.load)];
100
+ return [4 /*yield*/, this.repo.fromJsonArray(x.map(function (m) { return m.data.item; }), this.query.options)];
101
101
  case 1:
102
102
  loadedItems = _a.sent();
103
103
  for (index = 0; index < x.length; index++) {
@@ -3,7 +3,7 @@ import { LookupColumn } from '../column';
3
3
  import type { FieldMetadata, FieldOptions, ValueConverter, ValueListItem } from '../column-interfaces';
4
4
  import { Remult } from '../context';
5
5
  import type { EntityOptions } from '../entity';
6
- import type { ControllerRef, EntityFilter, EntityMetadata, EntityOrderBy, EntityRef, FieldRef, FieldsMetadata, FieldsRef, FindFirstOptions, FindFirstOptionsBase, FindOptions, IdMetadata, LiveQuery, OmitEB, QueryOptions, QueryResult, Repository, RepositoryRelations, Subscribable } from './remult3';
6
+ import type { ControllerRef, EntityFilter, EntityMetadata, EntityOrderBy, EntityRef, FieldRef, FieldsMetadata, FieldsRef, FindFirstOptions, FindFirstOptionsBase, FindOptions, IdMetadata, LiveQuery, LoadOptions, OmitEB, QueryOptions, QueryResult, Repository, RepositoryRelations, Subscribable } from './remult3';
7
7
  import type { RefSubscriber } from './remult3';
8
8
  import type { entityEventListener } from '../__EntityValueProvider';
9
9
  import type { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, ErrorInfo } from '../data-interfaces';
@@ -53,7 +53,7 @@ export declare class RepositoryImplementation<entityType> implements Repository<
53
53
  rawFind(options: FindOptions<entityType>, skipOrderByAndLimit: boolean, loader: RelationLoader): Promise<Awaited<entityType>[]>;
54
54
  find(options: FindOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType[]>;
55
55
  buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
56
- fromJsonArray(jsonItems: any[], load?: (entity: FieldsMetadata<entityType>) => FieldMetadata[]): Promise<Awaited<entityType>[]>;
56
+ fromJsonArray(jsonItems: any[], loadOptions: LoadOptions<entityType>): Promise<Awaited<entityType>[]>;
57
57
  private loadManyToOneForManyRows;
58
58
  private mapRawDataToResult;
59
59
  toJson(item: entityType | entityType[] | Promise<entityType> | Promise<entityType[]>): any;
@@ -125,7 +125,15 @@ var RepositoryImplementation = /** @class */ (function () {
125
125
  throw Error(key + ' is not a relation');
126
126
  var repo = _this.remult.repo(rel.toType());
127
127
  var findOptions = _this.findOptionsBasedOnRelation(rel, field, undefined, item, repo).findOptions;
128
- return new RepositoryImplementation(repo.entity, repo.remult, repo.dataProvider, repo._info, findOptions);
128
+ var toRepo = new RepositoryImplementation(repo.entity, repo.remult, repo.dataProvider, repo._info, findOptions);
129
+ if (rel.type === 'toMany')
130
+ return toRepo;
131
+ else
132
+ return {
133
+ findOne: function (options) {
134
+ return toRepo.findFirst({}, options);
135
+ },
136
+ };
129
137
  },
130
138
  });
131
139
  };
@@ -496,7 +504,7 @@ var RepositoryImplementation = /** @class */ (function () {
496
504
  return [4 /*yield*/, this.edp.find(opt)];
497
505
  case 2:
498
506
  rawRows = _a.sent();
499
- return [4 /*yield*/, this.loadManyToOneForManyRows(rawRows, options.load, options.include, loader)];
507
+ return [4 /*yield*/, this.loadManyToOneForManyRows(rawRows, options, loader)];
500
508
  case 3:
501
509
  result = _a.sent();
502
510
  return [2 /*return*/, result];
@@ -546,34 +554,43 @@ var RepositoryImplementation = /** @class */ (function () {
546
554
  });
547
555
  });
548
556
  };
549
- RepositoryImplementation.prototype.fromJsonArray = function (jsonItems, load) {
557
+ RepositoryImplementation.prototype.fromJsonArray = function (jsonItems, loadOptions) {
550
558
  return tslib_1.__awaiter(this, void 0, void 0, function () {
551
- var loader;
559
+ var loader, result;
552
560
  var _this = this;
553
561
  return tslib_1.__generator(this, function (_a) {
554
- loader = new relation_loader_1.RelationLoader();
555
- return [2 /*return*/, this.loadManyToOneForManyRows(jsonItems.map(function (row) {
556
- var e_7, _a;
557
- var result = {};
558
- try {
559
- for (var _b = tslib_1.__values(_this.metadata.fields.toArray()), _c = _b.next(); !_c.done; _c = _b.next()) {
560
- var col = _c.value;
561
- result[col.key] = col.valueConverter.fromJson(row[col.key]);
562
- }
563
- }
564
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
565
- finally {
566
- try {
567
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
568
- }
569
- finally { if (e_7) throw e_7.error; }
570
- }
571
- return result;
572
- }), load, undefined, loader)];
562
+ switch (_a.label) {
563
+ case 0:
564
+ loader = new relation_loader_1.RelationLoader();
565
+ return [4 /*yield*/, this.loadManyToOneForManyRows(jsonItems.map(function (row) {
566
+ var e_7, _a;
567
+ var result = {};
568
+ try {
569
+ for (var _b = tslib_1.__values(_this.metadata.fields.toArray()), _c = _b.next(); !_c.done; _c = _b.next()) {
570
+ var col = _c.value;
571
+ result[col.key] = col.valueConverter.fromJson(row[col.key]);
572
+ }
573
+ }
574
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
575
+ finally {
576
+ try {
577
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
578
+ }
579
+ finally { if (e_7) throw e_7.error; }
580
+ }
581
+ return result;
582
+ }), loadOptions, loader)];
583
+ case 1:
584
+ result = _a.sent();
585
+ return [4 /*yield*/, loader.resolveAll()];
586
+ case 2:
587
+ _a.sent();
588
+ return [2 /*return*/, result];
589
+ }
573
590
  });
574
591
  });
575
592
  };
576
- RepositoryImplementation.prototype.loadManyToOneForManyRows = function (rawRows, load, include, loader) {
593
+ RepositoryImplementation.prototype.loadManyToOneForManyRows = function (rawRows, loadOptions, loader) {
577
594
  var _a, _b;
578
595
  return tslib_1.__awaiter(this, void 0, void 0, function () {
579
596
  function loadManyToOne(repo, toLoad) {
@@ -603,15 +620,15 @@ var RepositoryImplementation = /** @class */ (function () {
603
620
  });
604
621
  });
605
622
  }
606
- var loadFields, _c, _d, col, ei, isRelation, load_1, repo, toLoad, rawRows_1, rawRows_1_1, r, val, rel, e_8_1, result, _loop_1, this_1, _e, _f, col;
623
+ var loadFields, _c, _d, col, ei, isRelation, load, repo, toLoad, rawRows_1, rawRows_1_1, r, val, rel, e_8_1, result, _loop_1, this_1, _e, _f, col;
607
624
  var e_8, _g, e_9, _h, e_10, _j;
608
625
  var _this = this;
609
626
  return tslib_1.__generator(this, function (_k) {
610
627
  switch (_k.label) {
611
628
  case 0:
612
629
  loadFields = undefined;
613
- if (load)
614
- loadFields = load(this.metadata.fields);
630
+ if (loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.load)
631
+ loadFields = loadOptions.load(this.metadata.fields);
615
632
  _k.label = 1;
616
633
  case 1:
617
634
  _k.trys.push([1, 8, 9, 10]);
@@ -624,14 +641,14 @@ var RepositoryImplementation = /** @class */ (function () {
624
641
  if (!ei) return [3 /*break*/, 5];
625
642
  isRelation = (_a = col.options) === null || _a === void 0 ? void 0 : _a[relationInfoMember_1.relationInfoMember];
626
643
  if (!!isRelation) return [3 /*break*/, 4];
627
- load_1 = isRelation
644
+ load = isRelation
628
645
  ? (_b = col.options) === null || _b === void 0 ? void 0 : _b.defaultIncluded
629
646
  : !col.options.lazy;
630
647
  if (loadFields !== undefined)
631
- load_1 = loadFields.includes(col);
632
- if (include)
633
- load_1 = include[col.key];
634
- if (!load_1) return [3 /*break*/, 4];
648
+ load = loadFields.includes(col);
649
+ if (loadOptions.include)
650
+ load = loadOptions.include[col.key];
651
+ if (!load) return [3 /*break*/, 4];
635
652
  repo = this.remult.repo(col.valueType);
636
653
  toLoad = [];
637
654
  try {
@@ -692,8 +709,8 @@ var RepositoryImplementation = /** @class */ (function () {
692
709
  var rel = (0, relationInfoMember_1.getRelationInfo)(col.options);
693
710
  var incl = col.options
694
711
  .defaultIncluded;
695
- if (include) {
696
- incl = include === null || include === void 0 ? void 0 : include[col.key];
712
+ if (loadOptions === null || loadOptions === void 0 ? void 0 : loadOptions.include) {
713
+ incl = loadOptions.include[col.key];
697
714
  }
698
715
  if (rel && incl) {
699
716
  var otherRepo = this_1.remult.repo(rel.toType());
@@ -2331,20 +2348,36 @@ var FieldRefImplementation = /** @class */ (function () {
2331
2348
  };
2332
2349
  FieldRefImplementation.prototype.load = function () {
2333
2350
  return tslib_1.__awaiter(this, void 0, void 0, function () {
2334
- var lu;
2335
- return tslib_1.__generator(this, function (_a) {
2336
- switch (_a.label) {
2351
+ var lu, rel, _a, _b, _c, _d;
2352
+ return tslib_1.__generator(this, function (_e) {
2353
+ switch (_e.label) {
2337
2354
  case 0:
2338
2355
  lu = this.rowBase.lookups.get(this.metadata.key);
2339
- if (!lu) return [3 /*break*/, 4];
2340
- if (!this.valueChanged()) return [3 /*break*/, 2];
2356
+ rel = (0, relationInfoMember_1.getRelationInfo)(this.metadata.options);
2357
+ if (!rel) return [3 /*break*/, 5];
2358
+ if (!(rel.type === 'toMany')) return [3 /*break*/, 2];
2359
+ _a = this.container;
2360
+ _b = this.metadata.key;
2361
+ return [4 /*yield*/, this.helper.repository
2362
+ .relations(this.container)[this.metadata.key].find()];
2363
+ case 1: return [2 /*return*/, (_a[_b] = _e.sent())];
2364
+ case 2:
2365
+ _c = this.container;
2366
+ _d = this.metadata.key;
2367
+ return [4 /*yield*/, this.helper.repository
2368
+ .relations(this.container)[this.metadata.key].findOne()];
2369
+ case 3: return [2 /*return*/, (_c[_d] = _e.sent())];
2370
+ case 4: return [3 /*break*/, 9];
2371
+ case 5:
2372
+ if (!lu) return [3 /*break*/, 9];
2373
+ if (!this.valueChanged()) return [3 /*break*/, 7];
2341
2374
  return [4 /*yield*/, lu.waitLoadOf(this.rawOriginalValue())];
2342
- case 1:
2343
- _a.sent();
2344
- _a.label = 2;
2345
- case 2: return [4 /*yield*/, lu.waitLoad()];
2346
- case 3: return [2 /*return*/, _a.sent()];
2347
- case 4: return [2 /*return*/, this.value];
2375
+ case 6:
2376
+ _e.sent();
2377
+ _e.label = 7;
2378
+ case 7: return [4 /*yield*/, lu.waitLoad()];
2379
+ case 8: return [2 /*return*/, _e.sent()];
2380
+ case 9: return [2 /*return*/, this.value];
2348
2381
  }
2349
2382
  });
2350
2383
  });
@@ -414,7 +414,7 @@ export type RelationOptionsBase<fromEntity, toEntity, optionsType extends LoadOp
414
414
  } & FieldOptions<fromEntity, toEntity>;
415
415
  export type ObjectMembersOnly<T> = {
416
416
  [K in keyof Pick<T, {
417
- [K in keyof T]: T[K] extends object ? T[K] extends Date ? never : K : never;
417
+ [K in keyof T]: T[K] extends object | undefined | null ? T[K] extends Date | undefined | null ? never : K : never;
418
418
  }[keyof T]>]: T[K];
419
419
  };
420
420
  export type MembersToInclude<T> = {
@@ -1,6 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //[ ] - implement find One
4
- //[ ] - for active record, implement waitLoad
5
- //[ ] - replace lookup Column with strategy for reference vs lazy
6
- //[ ] - test with live query
@@ -1,3 +1,3 @@
1
1
  import type { CompoundIdField } from './CompoundIdField';
2
2
  import { Filter } from './filter/filter-interfaces';
3
- export declare function resultCompoundIdFilter(idField: CompoundIdField, id: string, data: any): Filter;
3
+ export declare function resultCompoundIdFilter(idField: CompoundIdField, id: string | undefined, data: any): Filter;