@mikro-orm/core 7.0.0-dev.68 → 7.0.0-dev.69

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.
@@ -9,7 +9,7 @@ import { EntityLoader, type EntityLoaderOptions } from './entity/EntityLoader.js
9
9
  import { Reference } from './entity/Reference.js';
10
10
  import { UnitOfWork } from './unit-of-work/UnitOfWork.js';
11
11
  import type { CountOptions, DeleteOptions, FilterOptions, FindAllOptions, FindByCursorOptions, FindOneOptions, FindOneOrFailOptions, FindOptions, GetReferenceOptions, IDatabaseDriver, LockOptions, NativeInsertUpdateOptions, StreamOptions, UpdateOptions, UpsertManyOptions, UpsertOptions } from './drivers/IDatabaseDriver.js';
12
- import type { AnyEntity, AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, Primary, Ref, RequiredEntityData, UnboxArray } from './typings.js';
12
+ import type { AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, Primary, Ref, RequiredEntityData, UnboxArray } from './typings.js';
13
13
  import { FlushMode, LockMode, PopulatePath, type TransactionOptions } from './enums.js';
14
14
  import type { MetadataStorage } from './metadata/MetadataStorage.js';
15
15
  import type { Transaction } from './connections/Connection.js';
@@ -418,11 +418,6 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
418
418
  * The entity will be entered into the database at or before transaction commit or as a result of the flush operation.
419
419
  */
420
420
  persist<Entity extends object>(entity: Entity | Reference<Entity> | Iterable<Entity | Reference<Entity>>): this;
421
- /**
422
- * Persists your entity immediately, flushing all not yet persisted changes to the database too.
423
- * Equivalent to `em.persist(e).flush()`.
424
- */
425
- persistAndFlush(entity: AnyEntity | Reference<AnyEntity> | Iterable<AnyEntity | Reference<AnyEntity>>): Promise<void>;
426
421
  /**
427
422
  * Marks entity for removal.
428
423
  * A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.
@@ -430,11 +425,6 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
430
425
  * To remove entities by condition, use `em.nativeDelete()`.
431
426
  */
432
427
  remove<Entity extends object>(entity: Entity | Reference<Entity> | Iterable<Entity | Reference<Entity>>): this;
433
- /**
434
- * Removes an entity instance immediately, flushing all not yet persisted changes to the database too.
435
- * Equivalent to `em.remove(e).flush()`
436
- */
437
- removeAndFlush(entity: AnyEntity | Reference<AnyEntity> | Iterable<AnyEntity | Reference<AnyEntity>>): Promise<void>;
438
428
  /**
439
429
  * Flushes all changes to objects that have been queued up to now to the database.
440
430
  * This effectively synchronizes the in-memory state of managed objects with the database.
package/EntityManager.js CHANGED
@@ -1378,13 +1378,6 @@ export class EntityManager {
1378
1378
  }
1379
1379
  return this;
1380
1380
  }
1381
- /**
1382
- * Persists your entity immediately, flushing all not yet persisted changes to the database too.
1383
- * Equivalent to `em.persist(e).flush()`.
1384
- */
1385
- async persistAndFlush(entity) {
1386
- await this.persist(entity).flush();
1387
- }
1388
1381
  /**
1389
1382
  * Marks entity for removal.
1390
1383
  * A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.
@@ -1408,13 +1401,6 @@ export class EntityManager {
1408
1401
  }
1409
1402
  return em;
1410
1403
  }
1411
- /**
1412
- * Removes an entity instance immediately, flushing all not yet persisted changes to the database too.
1413
- * Equivalent to `em.remove(e).flush()`
1414
- */
1415
- async removeAndFlush(entity) {
1416
- await this.remove(entity).flush();
1417
- }
1418
1404
  /**
1419
1405
  * Flushes all changes to objects that have been queued up to now to the database.
1420
1406
  * This effectively synchronizes the in-memory state of managed objects with the database.
package/MikroORM.d.ts CHANGED
@@ -71,33 +71,17 @@ export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver,
71
71
  /**
72
72
  * Gets the SchemaGenerator.
73
73
  */
74
- getSchemaGenerator(): ReturnType<ReturnType<Driver['getPlatform']>['getSchemaGenerator']>;
75
- /**
76
- * Gets the EntityGenerator.
77
- */
78
- getEntityGenerator<T extends IEntityGenerator = IEntityGenerator>(): T;
79
- /**
80
- * Gets the Migrator.
81
- */
82
- getMigrator<T extends IMigrator = IMigrator>(): T;
74
+ get schema(): ReturnType<ReturnType<Driver['getPlatform']>['getSchemaGenerator']>;
83
75
  /**
84
76
  * Gets the SeedManager
85
77
  */
86
- getSeeder<T extends ISeedManager = ISeedManager>(): T;
87
- /**
88
- * Shortcut for `orm.getSchemaGenerator()`
89
- */
90
- get schema(): ReturnType<ReturnType<Driver["getPlatform"]>["getSchemaGenerator"]>;
91
- /**
92
- * Shortcut for `orm.getSeeder()`
93
- */
94
78
  get seeder(): ISeedManager;
95
79
  /**
96
- * Shortcut for `orm.getMigrator()`
80
+ * Gets the Migrator.
97
81
  */
98
82
  get migrator(): IMigrator;
99
83
  /**
100
- * Shortcut for `orm.getEntityGenerator()`
84
+ * Gets the EntityGenerator.
101
85
  */
102
86
  get entityGenerator(): IEntityGenerator;
103
87
  }
package/MikroORM.js CHANGED
@@ -134,54 +134,25 @@ export class MikroORM {
134
134
  /**
135
135
  * Gets the SchemaGenerator.
136
136
  */
137
- getSchemaGenerator() {
138
- const extension = this.config.getExtension('@mikro-orm/schema-generator');
139
- if (extension) {
140
- return extension;
141
- }
142
- /* v8 ignore next 2 */
143
- throw new Error(`SchemaGenerator extension not registered.`);
144
- }
145
- /**
146
- * Gets the EntityGenerator.
147
- */
148
- getEntityGenerator() {
149
- return this.driver.getPlatform().getExtension('EntityGenerator', '@mikro-orm/entity-generator', '@mikro-orm/entity-generator', this.em);
150
- }
151
- /**
152
- * Gets the Migrator.
153
- */
154
- getMigrator() {
155
- return this.driver.getPlatform().getExtension('Migrator', '@mikro-orm/migrator', '@mikro-orm/migrations', this.em);
156
- }
157
- /**
158
- * Gets the SeedManager
159
- */
160
- getSeeder() {
161
- return this.driver.getPlatform().getExtension('SeedManager', '@mikro-orm/seeder', '@mikro-orm/seeder', this.em);
162
- }
163
- /**
164
- * Shortcut for `orm.getSchemaGenerator()`
165
- */
166
137
  get schema() {
167
- return this.getSchemaGenerator();
138
+ return this.config.getExtension('@mikro-orm/schema-generator');
168
139
  }
169
140
  /**
170
- * Shortcut for `orm.getSeeder()`
141
+ * Gets the SeedManager
171
142
  */
172
143
  get seeder() {
173
- return this.getSeeder();
144
+ return this.driver.getPlatform().getExtension('SeedManager', '@mikro-orm/seeder', '@mikro-orm/seeder', this.em);
174
145
  }
175
146
  /**
176
- * Shortcut for `orm.getMigrator()`
147
+ * Gets the Migrator.
177
148
  */
178
149
  get migrator() {
179
- return this.getMigrator();
150
+ return this.driver.getPlatform().getExtension('Migrator', '@mikro-orm/migrator', '@mikro-orm/migrations', this.em);
180
151
  }
181
152
  /**
182
- * Shortcut for `orm.getEntityGenerator()`
153
+ * Gets the EntityGenerator.
183
154
  */
184
155
  get entityGenerator() {
185
- return this.getEntityGenerator();
156
+ return this.driver.getPlatform().getExtension('EntityGenerator', '@mikro-orm/entity-generator', '@mikro-orm/entity-generator', this.em);
186
157
  }
187
158
  }
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.68",
4
+ "version": "7.0.0-dev.69",
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",
@@ -51,9 +51,6 @@
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "dependencies": {
55
- "mikro-orm": "7.0.0-dev.68"
56
- },
57
54
  "peerDependencies": {
58
55
  "dataloader": "2.2.3"
59
56
  },
package/typings.d.ts CHANGED
@@ -544,25 +544,25 @@ export interface RefreshDatabaseOptions extends CreateSchemaOptions {
544
544
  createSchema?: boolean;
545
545
  }
546
546
  export interface ISchemaGenerator {
547
- createSchema(options?: CreateSchemaOptions): Promise<void>;
548
- ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
547
+ create(options?: CreateSchemaOptions): Promise<void>;
548
+ update(options?: UpdateSchemaOptions): Promise<void>;
549
+ drop(options?: DropSchemaOptions): Promise<void>;
550
+ refresh(options?: RefreshDatabaseOptions): Promise<void>;
551
+ clear(options?: ClearDatabaseOptions): Promise<void>;
552
+ execute(sql: string, options?: {
553
+ wrap?: boolean;
554
+ }): Promise<void>;
549
555
  getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
550
- dropSchema(options?: DropSchemaOptions): Promise<void>;
551
556
  getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
552
- updateSchema(options?: UpdateSchemaOptions): Promise<void>;
553
557
  getUpdateSchemaSQL(options?: UpdateSchemaOptions): Promise<string>;
554
558
  getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions): Promise<{
555
559
  up: string;
556
560
  down: string;
557
561
  }>;
562
+ ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
558
563
  createDatabase(name?: string): Promise<void>;
559
564
  dropDatabase(name?: string): Promise<void>;
560
- execute(sql: string, options?: {
561
- wrap?: boolean;
562
- }): Promise<void>;
563
565
  ensureIndexes(): Promise<void>;
564
- refreshDatabase(options?: RefreshDatabaseOptions): Promise<void>;
565
- clearDatabase(options?: ClearDatabaseOptions): Promise<void>;
566
566
  }
567
567
  export type ImportsResolver = (alias: string, basePath: string, extension: '.js' | '', originFileName: string) => {
568
568
  path: string;
@@ -642,26 +642,26 @@ export interface IMigrator {
642
642
  /**
643
643
  * Checks current schema for changes, generates new migration if there are any.
644
644
  */
645
- createMigration(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
645
+ create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
646
646
  /**
647
647
  * Checks current schema for changes.
648
648
  */
649
- checkMigrationNeeded(): Promise<boolean>;
649
+ checkSchema(): Promise<boolean>;
650
650
  /**
651
651
  * Creates initial migration. This generates the schema based on metadata, and checks whether all the tables
652
652
  * are already present. If yes, it will also automatically log the migration as executed.
653
653
  * Initial migration can be created only if the schema is already aligned with the metadata, or when no schema
654
654
  * is present - in such case regular migration would have the same effect.
655
655
  */
656
- createInitialMigration(path?: string): Promise<MigrationResult>;
656
+ createInitial(path?: string): Promise<MigrationResult>;
657
657
  /**
658
658
  * Returns list of already executed migrations.
659
659
  */
660
- getExecutedMigrations(): Promise<MigrationRow[]>;
660
+ getExecuted(): Promise<MigrationRow[]>;
661
661
  /**
662
662
  * Returns list of pending (not yet executed) migrations found in the migration directory.
663
663
  */
664
- getPendingMigrations(): Promise<UmzugMigration[]>;
664
+ getPending(): Promise<UmzugMigration[]>;
665
665
  /**
666
666
  * Executes specified migrations. Without parameter it will migrate up to the latest version.
667
667
  */
@@ -838,7 +838,7 @@ export interface ISeedManager {
838
838
  seed(...classNames: Constructor<Seeder>[]): Promise<void>;
839
839
  /** @internal */
840
840
  seedString(...classNames: string[]): Promise<void>;
841
- createSeeder(className: string): Promise<string>;
841
+ create(className: string): Promise<string>;
842
842
  }
843
843
  export interface Seeder<T extends Dictionary = Dictionary> {
844
844
  run(em: EntityManager, context?: T): void | Promise<void>;
@@ -10,18 +10,18 @@ export declare abstract class AbstractSchemaGenerator<D extends IDatabaseDriver>
10
10
  protected readonly platform: ReturnType<D['getPlatform']>;
11
11
  protected readonly connection: ReturnType<D['getConnection']>;
12
12
  constructor(em: D | D[typeof EntityManagerType]);
13
- createSchema(options?: CreateSchemaOptions): Promise<void>;
13
+ create(options?: CreateSchemaOptions): Promise<void>;
14
14
  /**
15
15
  * Returns true if the database was created.
16
16
  */
17
17
  ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
18
- refreshDatabase(options?: RefreshDatabaseOptions): Promise<void>;
19
- clearDatabase(options?: ClearDatabaseOptions): Promise<void>;
18
+ refresh(options?: RefreshDatabaseOptions): Promise<void>;
19
+ clear(options?: ClearDatabaseOptions): Promise<void>;
20
20
  protected clearIdentityMap(): void;
21
21
  getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
22
- dropSchema(options?: DropSchemaOptions): Promise<void>;
22
+ drop(options?: DropSchemaOptions): Promise<void>;
23
23
  getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
24
- updateSchema(options?: UpdateSchemaOptions): Promise<void>;
24
+ update(options?: UpdateSchemaOptions): Promise<void>;
25
25
  getUpdateSchemaSQL(options?: UpdateSchemaOptions): Promise<string>;
26
26
  getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions): Promise<{
27
27
  up: string;
@@ -15,7 +15,7 @@ export class AbstractSchemaGenerator {
15
15
  this.platform = this.driver.getPlatform();
16
16
  this.connection = this.driver.getConnection();
17
17
  }
18
- async createSchema(options) {
18
+ async create(options) {
19
19
  this.notImplemented();
20
20
  }
21
21
  /**
@@ -24,7 +24,7 @@ export class AbstractSchemaGenerator {
24
24
  async ensureDatabase(options) {
25
25
  this.notImplemented();
26
26
  }
27
- async refreshDatabase(options) {
27
+ async refresh(options) {
28
28
  if (options?.dropDb) {
29
29
  const name = this.config.get('dbName');
30
30
  await this.dropDatabase(name);
@@ -32,13 +32,13 @@ export class AbstractSchemaGenerator {
32
32
  }
33
33
  else {
34
34
  await this.ensureDatabase();
35
- await this.dropSchema(options);
35
+ await this.drop(options);
36
36
  }
37
37
  if (options?.createSchema !== false) {
38
- await this.createSchema(options);
38
+ await this.create(options);
39
39
  }
40
40
  }
41
- async clearDatabase(options) {
41
+ async clear(options) {
42
42
  for (const meta of this.getOrderedMetadata(options?.schema).reverse()) {
43
43
  await this.driver.nativeDelete(meta.className, {}, options);
44
44
  }
@@ -59,13 +59,13 @@ export class AbstractSchemaGenerator {
59
59
  async getCreateSchemaSQL(options) {
60
60
  this.notImplemented();
61
61
  }
62
- async dropSchema(options) {
62
+ async drop(options) {
63
63
  this.notImplemented();
64
64
  }
65
65
  async getDropSchemaSQL(options) {
66
66
  this.notImplemented();
67
67
  }
68
- async updateSchema(options) {
68
+ async update(options) {
69
69
  this.notImplemented();
70
70
  }
71
71
  async getUpdateSchemaSQL(options) {