remult 0.22.7 → 0.22.8-exp.0

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/column.js CHANGED
@@ -14,6 +14,8 @@ export class LookupColumn {
14
14
  repository;
15
15
  id;
16
16
  toJson() {
17
+ if (!this.storedItem)
18
+ return undefined;
17
19
  if (this.item === null)
18
20
  return null;
19
21
  return this.repository.toJson(this.item);
@@ -874,7 +874,15 @@ export class rowHelperImplementation extends rowHelperBase {
874
874
  }
875
875
  metadata;
876
876
  getId() {
877
- return this.info.idMetadata.getId(this.instance);
877
+ const getVal = (y) => {
878
+ let z = this.lookups.get(y.key);
879
+ if (z)
880
+ return z.id;
881
+ return this.instance[y.key];
882
+ };
883
+ if (this.metadata.idMetadata.field instanceof CompoundIdField)
884
+ return this.metadata.idMetadata.field.fields.map(getVal).join(',');
885
+ return getVal(this.metadata.idMetadata.field);
878
886
  }
879
887
  saveMoreOriginalData() {
880
888
  this.originalId = this.getId();
@@ -1513,6 +1521,9 @@ class EntityFullInfo {
1513
1521
  }
1514
1522
  idMetadata = {
1515
1523
  getId: (item) => {
1524
+ const ref = getEntityRef(item, false);
1525
+ if (ref)
1526
+ return ref.getId();
1516
1527
  if (this.idMetadata.field instanceof CompoundIdField)
1517
1528
  return this.idMetadata.field.getId(item);
1518
1529
  else
@@ -5,6 +5,7 @@ import type { FieldMetadata } from '../column-interfaces';
5
5
  import type { EntityOptions } from '../entity';
6
6
  import type { LiveQueryChange, SubscriptionListener, Unsubscribe } from '../live-query/SubscriptionChannel';
7
7
  import type { SortSegment } from '../sort';
8
+ import type { EntityBase } from './RepositoryImplementation';
8
9
  export interface EntityRef<entityType> extends Subscribable {
9
10
  hasErrors(): boolean;
10
11
  undoChanges(): any;
@@ -153,7 +154,7 @@ export interface EntityMetadata<entityType = any> {
153
154
  /** Metadata for the Entity's id */
154
155
  readonly idMetadata: IdMetadata<entityType>;
155
156
  }
156
- export declare type OmitEB<T> = Omit<T, keyof import('./RepositoryImplementation').EntityBase>;
157
+ export declare type OmitEB<T> = Omit<T, keyof EntityBase>;
157
158
  export declare type idType<entityType> = entityType extends {
158
159
  id?: number;
159
160
  } ? number : entityType extends {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.22.7",
3
+ "version": "0.22.8-exp.0",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "types": "index.d.ts",
6
6
  "module": "esm/index.js",
package/src/column.js CHANGED
@@ -21,6 +21,8 @@ var LookupColumn = /** @class */ (function () {
21
21
  this.id = id;
22
22
  }
23
23
  LookupColumn.prototype.toJson = function () {
24
+ if (!this.storedItem)
25
+ return undefined;
24
26
  if (this.item === null)
25
27
  return null;
26
28
  return this.repository.toJson(this.item);
@@ -1436,7 +1436,16 @@ var rowHelperImplementation = /** @class */ (function (_super) {
1436
1436
  configurable: true
1437
1437
  });
1438
1438
  rowHelperImplementation.prototype.getId = function () {
1439
- return this.info.idMetadata.getId(this.instance);
1439
+ var _this = this;
1440
+ var getVal = function (y) {
1441
+ var z = _this.lookups.get(y.key);
1442
+ if (z)
1443
+ return z.id;
1444
+ return _this.instance[y.key];
1445
+ };
1446
+ if (this.metadata.idMetadata.field instanceof CompoundIdField_1.CompoundIdField)
1447
+ return this.metadata.idMetadata.field.fields.map(getVal).join(',');
1448
+ return getVal(this.metadata.idMetadata.field);
1440
1449
  };
1441
1450
  rowHelperImplementation.prototype.saveMoreOriginalData = function () {
1442
1451
  this.originalId = this.getId();
@@ -2413,6 +2422,9 @@ var EntityFullInfo = /** @class */ (function () {
2413
2422
  this.key = key;
2414
2423
  this.idMetadata = {
2415
2424
  getId: function (item) {
2425
+ var ref = (0, getEntityRef_1.getEntityRef)(item, false);
2426
+ if (ref)
2427
+ return ref.getId();
2416
2428
  if (_this.idMetadata.field instanceof CompoundIdField_1.CompoundIdField)
2417
2429
  return _this.idMetadata.field.getId(item);
2418
2430
  else
@@ -5,6 +5,7 @@ import type { FieldMetadata } from '../column-interfaces';
5
5
  import type { EntityOptions } from '../entity';
6
6
  import type { LiveQueryChange, SubscriptionListener, Unsubscribe } from '../live-query/SubscriptionChannel';
7
7
  import type { SortSegment } from '../sort';
8
+ import type { EntityBase } from './RepositoryImplementation';
8
9
  export interface EntityRef<entityType> extends Subscribable {
9
10
  hasErrors(): boolean;
10
11
  undoChanges(): any;
@@ -153,7 +154,7 @@ export interface EntityMetadata<entityType = any> {
153
154
  /** Metadata for the Entity's id */
154
155
  readonly idMetadata: IdMetadata<entityType>;
155
156
  }
156
- export declare type OmitEB<T> = Omit<T, keyof import('./RepositoryImplementation').EntityBase>;
157
+ export declare type OmitEB<T> = Omit<T, keyof EntityBase>;
157
158
  export declare type idType<entityType> = entityType extends {
158
159
  id?: number;
159
160
  } ? number : entityType extends {