@mikro-orm/core 7.0.0-dev.265 → 7.0.0-dev.267

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.
@@ -456,7 +456,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
456
456
  /**
457
457
  * Loads specified relations in batch. This will execute one query for each relation, that will populate it on all the specified entities.
458
458
  */
459
- populate<Entity extends object, Naked extends FromEntityType<UnboxArray<Entity>> = FromEntityType<UnboxArray<Entity>>, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entities: Entity, populate: readonly AutoPath<Naked, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Naked, Fields, Excludes>): Promise<Entity extends object[] ? MergeLoaded<ArrayElement<Entity>, Naked, Hint, Fields, Excludes>[] : MergeLoaded<Entity, Naked, Hint, Fields, Excludes>>;
459
+ populate<Entity extends object, Naked extends FromEntityType<UnboxArray<Entity>> = FromEntityType<UnboxArray<Entity>>, Hint extends string = never, Fields extends string = never, Excludes extends string = never>(entities: Entity, populate: readonly AutoPath<Naked, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Naked, Fields, Excludes>): Promise<Entity extends object[] ? MergeLoaded<ArrayElement<Entity>, Naked, Hint, Fields, Excludes>[] : MergeLoaded<Entity, Naked, Hint, Fields, Excludes>>;
460
460
  /**
461
461
  * Returns new EntityManager instance with its own identity map
462
462
  */
@@ -1,4 +1,4 @@
1
- import type { ConnectionType, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName, PopulateHintOptions, Prefixes } from '../typings.js';
1
+ import type { ConnectionType, Constructor, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName, PopulateHintOptions, Prefixes } from '../typings.js';
2
2
  import type { Connection, QueryResult, Transaction } from '../connections/Connection.js';
3
3
  import type { FlushMode, LockMode, QueryOrderMap, QueryFlag, LoadStrategy, PopulateHint, PopulatePath } from '../enums.js';
4
4
  import type { Platform } from '../platforms/Platform.js';
@@ -7,6 +7,7 @@ import type { Collection } from '../entity/Collection.js';
7
7
  import type { EntityManager } from '../EntityManager.js';
8
8
  import type { DriverException } from '../exceptions.js';
9
9
  import type { Configuration } from '../utils/Configuration.js';
10
+ import type { MikroORM } from '../MikroORM.js';
10
11
  import type { LoggingOptions, LogContext } from '../logging/Logger.js';
11
12
  import type { Raw } from '../utils/RawQueryFragment.js';
12
13
  export declare const EntityManagerType: unique symbol;
@@ -65,6 +66,10 @@ export interface IDatabaseDriver<C extends Connection = Connection> {
65
66
  schema?: string;
66
67
  parentSchema?: string;
67
68
  }): string | undefined;
69
+ /**
70
+ * @internal
71
+ */
72
+ getORMClass(): Constructor<MikroORM>;
68
73
  }
69
74
  export type EntityField<T, P extends string = PopulatePath.ALL> = keyof T | PopulatePath.ALL | AutoPath<T, P, `${PopulatePath.ALL}`>;
70
75
  export type OrderDefinition<T> = (QueryOrderMap<T> & {
@@ -8,7 +8,7 @@ import type { PopulatePath } from '../enums.js';
8
8
  export declare abstract class BaseEntity {
9
9
  isInitialized(): boolean;
10
10
  populated(populated?: boolean): void;
11
- populate<Entity extends this = this, Hint extends string = never>(populate: AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
11
+ populate<Entity extends this = this, Hint extends string = never, Fields extends string = never>(populate: AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity, Fields>): Promise<Loaded<Entity, Hint>>;
12
12
  toReference<Entity extends this = this>(): Ref<Entity> & LoadedReference<Loaded<Entity, AddEager<Entity>>>;
13
13
  /**
14
14
  * Converts the entity to a plain object representation.
@@ -1,13 +1,13 @@
1
- import type { AnyEntity, ConnectionType, EntityName, EntityProperty, FilterQuery, PopulateOptions } from '../typings.js';
1
+ import type { AnyEntity, AutoPath, ConnectionType, EntityName, EntityProperty, FilterQuery, PopulateOptions } from '../typings.js';
2
2
  import type { EntityManager } from '../EntityManager.js';
3
3
  import { LoadStrategy, type LockMode, type PopulateHint, PopulatePath, type QueryOrderMap } from '../enums.js';
4
- import type { EntityField, FilterOptions } from '../drivers/IDatabaseDriver.js';
4
+ import type { FilterOptions } from '../drivers/IDatabaseDriver.js';
5
5
  import type { LoggingOptions } from '../logging/Logger.js';
6
- export type EntityLoaderOptions<Entity, Fields extends string = PopulatePath.ALL, Excludes extends string = never> = {
6
+ export interface EntityLoaderOptions<Entity, Fields extends string = PopulatePath.ALL, Excludes extends string = never> {
7
+ fields?: readonly AutoPath<Entity, Fields, `${PopulatePath.ALL}`>[];
8
+ exclude?: readonly AutoPath<Entity, Excludes>[];
7
9
  where?: FilterQuery<Entity>;
8
10
  populateWhere?: PopulateHint | `${PopulateHint}`;
9
- fields?: readonly EntityField<Entity, Fields>[];
10
- exclude?: readonly EntityField<Entity, Excludes>[];
11
11
  orderBy?: QueryOrderMap<Entity> | QueryOrderMap<Entity>[];
12
12
  refresh?: boolean;
13
13
  validate?: boolean;
@@ -20,7 +20,7 @@ export type EntityLoaderOptions<Entity, Fields extends string = PopulatePath.ALL
20
20
  schema?: string;
21
21
  connectionType?: ConnectionType;
22
22
  logging?: LoggingOptions;
23
- };
23
+ }
24
24
  export declare class EntityLoader {
25
25
  private readonly em;
26
26
  private readonly metadata;
@@ -150,7 +150,7 @@ export declare class EntityRepository<Entity extends object> {
150
150
  /**
151
151
  * Loads specified relations in batch. This will execute one query for each relation, that will populate it on all the specified entities.
152
152
  */
153
- populate<Ent extends Entity | Entity[], Hint extends string = never, Naked extends FromEntityType<Entity> = FromEntityType<Entity>, Fields extends string = '*', Excludes extends string = never>(entities: Ent, populate: AutoPath<Naked, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Naked, Fields, Excludes>): Promise<Ent extends object[] ? MergeLoaded<ArrayElement<Ent>, Naked, Hint, Fields, Excludes>[] : MergeLoaded<Ent, Naked, Hint, Fields, Excludes>>;
153
+ populate<Ent extends Entity | Entity[], Hint extends string = never, Naked extends FromEntityType<Entity> = FromEntityType<Entity>, Fields extends string = never, Excludes extends string = never>(entities: Ent, populate: AutoPath<Naked, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Naked, Fields, Excludes>): Promise<Ent extends object[] ? MergeLoaded<ArrayElement<Ent>, Naked, Hint, Fields, Excludes>[] : MergeLoaded<Ent, Naked, Hint, Fields, Excludes>>;
154
154
  /**
155
155
  * Creates new instance of given entity and populates it with given data.
156
156
  * The entity constructor will be used unless you provide `{ managed: true }` in the `options` parameter.
@@ -49,7 +49,7 @@ export declare class WrappedEntity<Entity extends object> {
49
49
  toJSON(...args: any[]): EntityDictionary<Entity>;
50
50
  assign<Naked extends FromEntityType<Entity> = FromEntityType<Entity>, Convert extends boolean = false, Data extends EntityData<Naked, Convert> | Partial<EntityDTO<Naked>> = EntityData<Naked, Convert> | Partial<EntityDTO<Naked>>>(data: Data & IsSubset<EntityData<Naked>, Data>, options?: AssignOptions<Convert>): MergeSelected<Entity, Naked, keyof Data & string>;
51
51
  init<Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(options?: FindOneOptions<Entity, Hint, Fields, Excludes>): Promise<Loaded<Entity, Hint, Fields, Excludes> | null>;
52
- populate<Hint extends string = never>(populate: AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
52
+ populate<Hint extends string = never, Fields extends string = never>(populate: AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity, Fields>): Promise<Loaded<Entity, Hint>>;
53
53
  hasPrimaryKey(): boolean;
54
54
  getPrimaryKey(convertCustomTypes?: boolean): Primary<Entity> | null;
55
55
  getPrimaryKeys(convertCustomTypes?: boolean): Primary<Entity>[] | null;
@@ -1474,7 +1474,7 @@ export class MetadataDiscovery {
1474
1474
  }
1475
1475
  /* v8 ignore next */
1476
1476
  if (prop.default != null) {
1477
- return '' + this.platform.quoteVersionValue(prop.default, prop);
1477
+ return '' + this.platform.convertVersionValue(prop.default, prop);
1478
1478
  }
1479
1479
  this.initCustomType(meta, prop, true);
1480
1480
  const type = prop.customType?.runtimeType ?? prop.runtimeType ?? prop.type;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.265",
4
+ "version": "7.0.0-dev.267",
5
5
  "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.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -66,7 +66,9 @@ export declare abstract class Platform {
66
66
  $flags?: string;
67
67
  };
68
68
  isAllowedTopLevelOperator(operator: string): boolean;
69
- quoteVersionValue(value: Date | number, prop: EntityProperty): Date | string | number;
69
+ convertVersionValue(value: Date | number, prop: EntityProperty): Date | string | number | {
70
+ $in: (string | number)[];
71
+ };
70
72
  getDefaultVersionLength(): number;
71
73
  allowsComparingTuples(): boolean;
72
74
  isBigIntProperty(prop: EntityProperty): boolean;
@@ -113,7 +113,7 @@ export class Platform {
113
113
  isAllowedTopLevelOperator(operator) {
114
114
  return operator === '$not';
115
115
  }
116
- quoteVersionValue(value, prop) {
116
+ convertVersionValue(value, prop) {
117
117
  return value;
118
118
  }
119
119
  getDefaultVersionLength() {
@@ -58,10 +58,12 @@ export class EntityTransformer {
58
58
  continue;
59
59
  }
60
60
  const populated = root.isMarkedAsPopulated(meta.class, prop);
61
- const partiallyLoaded = root.isPartiallyLoaded(meta.class, prop);
62
- const isPrimary = includePrimaryKeys && meta.properties[prop].primary;
63
- if (!partiallyLoaded && !populated && !isPrimary) {
64
- continue;
61
+ if (!raw) {
62
+ const partiallyLoaded = root.isPartiallyLoaded(meta.class, prop);
63
+ const isPrimary = includePrimaryKeys && meta.properties[prop].primary;
64
+ if (!partiallyLoaded && !populated && !isPrimary) {
65
+ continue;
66
+ }
65
67
  }
66
68
  const cycle = root.visit(meta.class, prop);
67
69
  if (cycle && visited) {
package/typings.d.ts CHANGED
@@ -247,7 +247,7 @@ export interface IWrappedEntity<Entity extends object> {
247
247
  isInitialized(): boolean;
248
248
  isManaged(): boolean;
249
249
  populated(populated?: boolean): void;
250
- populate<Hint extends string = never>(populate: readonly AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
250
+ populate<Hint extends string = never, Fields extends string = never>(populate: readonly AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity, Fields>): Promise<Loaded<Entity, Hint>>;
251
251
  init<Hint extends string = never, Fields extends string = '*', Exclude extends string = never>(options?: FindOneOptions<Entity, Hint, Fields, Exclude>): Promise<Loaded<Entity, Hint, Fields, Exclude> | null>;
252
252
  toReference(): Ref<Entity> & LoadedReference<Loaded<Entity, AddEager<Entity>>>;
253
253
  toObject(): EntityDTO<Entity>;
@@ -272,7 +272,7 @@ export class ChangeSetPersister {
272
272
  return this.driver.nativeUpdate(changeSet.meta.class, cond, changeSet.payload, options);
273
273
  }
274
274
  if (meta.versionProperty) {
275
- cond[meta.versionProperty] = this.platform.quoteVersionValue(changeSet.entity[meta.versionProperty], meta.properties[meta.versionProperty]);
275
+ cond[meta.versionProperty] = this.platform.convertVersionValue(changeSet.entity[meta.versionProperty], meta.properties[meta.versionProperty]);
276
276
  }
277
277
  this.checkConcurrencyKeys(meta, changeSet, cond);
278
278
  return this.driver.nativeUpdate(changeSet.meta.class, cond, changeSet.payload, options);
@@ -287,7 +287,7 @@ export class ChangeSetPersister {
287
287
  const cond = Utils.getPrimaryKeyCond(cs.originalEntity, meta.primaryKeys.concat(...meta.concurrencyCheckKeys));
288
288
  if (meta.versionProperty) {
289
289
  // @ts-ignore
290
- cond[meta.versionProperty] = this.platform.quoteVersionValue(cs.entity[meta.versionProperty], meta.properties[meta.versionProperty]);
290
+ cond[meta.versionProperty] = this.platform.convertVersionValue(cs.entity[meta.versionProperty], meta.properties[meta.versionProperty]);
291
291
  }
292
292
  return cond;
293
293
  });
package/utils/Utils.js CHANGED
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
123
123
  }
124
124
  export class Utils {
125
125
  static PK_SEPARATOR = '~~~';
126
- static #ORM_VERSION = '7.0.0-dev.265';
126
+ static #ORM_VERSION = '7.0.0-dev.267';
127
127
  /**
128
128
  * Checks if the argument is instance of `Object`. Returns false for arrays.
129
129
  */