@mikro-orm/core 6.3.14-dev.45 → 6.3.14-dev.47

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/EntityManager.js CHANGED
@@ -623,7 +623,7 @@ class EntityManager {
623
623
  const convertCustomTypes = !utils_1.Utils.isEntity(data);
624
624
  if (utils_1.Utils.isEntity(data)) {
625
625
  entity = data;
626
- if ((0, entity_1.helper)(entity).__managed && (0, entity_1.helper)(entity).__em === em) {
626
+ if ((0, entity_1.helper)(entity).__managed && (0, entity_1.helper)(entity).__em === em && !this.config.get('upsertManaged')) {
627
627
  em.entityFactory.mergeData(meta, entity, data, { initialized: true });
628
628
  return entity;
629
629
  }
@@ -633,7 +633,7 @@ class EntityManager {
633
633
  else {
634
634
  data = utils_1.Utils.copy(utils_1.QueryHelper.processParams(data));
635
635
  where = utils_1.Utils.extractPK(data, meta);
636
- if (where) {
636
+ if (where && !this.config.get('upsertManaged')) {
637
637
  const exists = em.unitOfWork.getById(entityName, where, options.schema);
638
638
  if (exists) {
639
639
  return em.assign(exists, data);
@@ -763,7 +763,7 @@ class EntityManager {
763
763
  let where;
764
764
  if (utils_1.Utils.isEntity(row)) {
765
765
  const entity = row;
766
- if ((0, entity_1.helper)(entity).__managed && (0, entity_1.helper)(entity).__em === em) {
766
+ if ((0, entity_1.helper)(entity).__managed && (0, entity_1.helper)(entity).__em === em && !this.config.get('upsertManaged')) {
767
767
  em.entityFactory.mergeData(meta, entity, row, { initialized: true });
768
768
  entities.set(entity, row);
769
769
  entitiesByData.set(row, entity);
@@ -775,7 +775,7 @@ class EntityManager {
775
775
  else {
776
776
  row = data[i] = utils_1.Utils.copy(utils_1.QueryHelper.processParams(row));
777
777
  where = utils_1.Utils.extractPK(row, meta);
778
- if (where) {
778
+ if (where && !this.config.get('upsertManaged')) {
779
779
  const exists = em.unitOfWork.getById(entityName, where, options.schema);
780
780
  if (exists) {
781
781
  em.assign(exists, row);
package/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * @module core
4
4
  */
5
- export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, } from './typings';
5
+ export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, } from './typings';
6
6
  export * from './enums';
7
7
  export * from './errors';
8
8
  export * from './exceptions';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.3.14-dev.45",
3
+ "version": "6.3.14-dev.47",
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.2.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.3.14-dev.45",
67
+ "mikro-orm": "6.3.14-dev.47",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
package/typings.d.ts CHANGED
@@ -627,11 +627,20 @@ export interface IMigrator {
627
627
  * Executes down migrations to the given point. Without parameter it will migrate one version down.
628
628
  */
629
629
  down(options?: string | string[] | MigrateOptions): Promise<UmzugMigration[]>;
630
+ /**
631
+ * Registers event handler.
632
+ */
633
+ on(event: MigratorEvent, listener: (event: UmzugMigration) => MaybePromise<void>): IMigrator;
634
+ /**
635
+ * Removes event handler.
636
+ */
637
+ off(event: MigratorEvent, listener: (event: UmzugMigration) => MaybePromise<void>): IMigrator;
630
638
  /**
631
639
  * @internal
632
640
  */
633
641
  getStorage(): IMigratorStorage;
634
642
  }
643
+ export type MigratorEvent = 'migrating' | 'migrated' | 'reverting' | 'reverted';
635
644
  export interface MigrationDiff {
636
645
  up: string[];
637
646
  down: string[];
@@ -71,6 +71,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
71
71
  mergeEmbeddedProperties: true;
72
72
  };
73
73
  persistOnCreate: true;
74
+ upsertManaged: true;
74
75
  forceEntityConstructor: false;
75
76
  forceUndefined: false;
76
77
  ensureDatabase: true;
@@ -333,6 +334,7 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
333
334
  };
334
335
  assign: AssignOptions<boolean>;
335
336
  persistOnCreate: boolean;
337
+ upsertManaged: boolean;
336
338
  forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
337
339
  forceUndefined: boolean;
338
340
  forceUtcTimezone?: boolean;
@@ -65,6 +65,7 @@ class Configuration {
65
65
  mergeEmbeddedProperties: true,
66
66
  },
67
67
  persistOnCreate: true,
68
+ upsertManaged: true,
68
69
  forceEntityConstructor: false,
69
70
  forceUndefined: false,
70
71
  ensureDatabase: true,