@mikro-orm/core 6.4.8-dev.7 → 6.4.8-dev.9

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.
@@ -14,7 +14,7 @@ export declare class ArrayCollection<T extends object, O extends object> {
14
14
  getItems(): T[];
15
15
  toArray<TT extends T>(): EntityDTO<TT>[];
16
16
  toJSON(): EntityDTO<T>[];
17
- getIdentifiers<U extends IPrimaryKey = Primary<T> & IPrimaryKey>(field?: string): U[];
17
+ getIdentifiers<U extends IPrimaryKey = Primary<T> & IPrimaryKey>(field?: string | string[]): U[];
18
18
  add(entity: T | Reference<T> | Iterable<T | Reference<T>>, ...entities: (T | Reference<T>)[]): void;
19
19
  /**
20
20
  * @internal
@@ -43,15 +43,22 @@ class ArrayCollection {
43
43
  }
44
44
  getIdentifiers(field) {
45
45
  const items = this.getItems();
46
+ const targetMeta = this.property.targetMeta;
46
47
  if (items.length === 0) {
47
48
  return [];
48
49
  }
49
- field ??= this.property.targetMeta.serializedPrimaryKey;
50
+ field ??= targetMeta.compositePK ? targetMeta.primaryKeys : targetMeta.serializedPrimaryKey;
51
+ const cb = (i, f) => {
52
+ if (Utils_1.Utils.isEntity(i[f], true)) {
53
+ return (0, wrap_1.wrap)(i[f], true).getPrimaryKey();
54
+ }
55
+ return i[f];
56
+ };
50
57
  return items.map(i => {
51
- if (Utils_1.Utils.isEntity(i[field], true)) {
52
- return (0, wrap_1.wrap)(i[field], true).getPrimaryKey();
58
+ if (Array.isArray(field)) {
59
+ return field.map(f => cb(i, f));
53
60
  }
54
- return i[field];
61
+ return cb(i, field);
55
62
  });
56
63
  }
57
64
  add(entity, ...entities) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.4.8-dev.7",
3
+ "version": "6.4.8-dev.9",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.3.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.4.8-dev.7",
67
+ "mikro-orm": "6.4.8-dev.9",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -13,4 +13,5 @@ export declare class BigIntType extends Type<string | bigint | number | null | u
13
13
  toJSON(value: string | bigint | null | undefined): string | bigint | null | undefined;
14
14
  getColumnType(prop: EntityProperty, platform: Platform): string;
15
15
  compareAsType(): string;
16
+ compareValues(a: string, b: string): boolean;
16
17
  }
@@ -44,5 +44,8 @@ class BigIntType extends Type_1.Type {
44
44
  compareAsType() {
45
45
  return this.mode ?? 'bigint';
46
46
  }
47
+ compareValues(a, b) {
48
+ return String(a) === String(b);
49
+ }
47
50
  }
48
51
  exports.BigIntType = BigIntType;