@mikro-orm/migrations-mongodb 7.0.4 → 7.0.5-dev.1

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.
@@ -1,14 +1,11 @@
1
1
  import { MigrationGenerator } from './MigrationGenerator.js';
2
2
  /** Generates MongoDB migration files in CommonJS JavaScript format. */
3
3
  export declare class JSMigrationGenerator extends MigrationGenerator {
4
- /**
5
- * @inheritDoc
6
- */
7
- generateMigrationFile(
8
- className: string,
9
- diff: {
10
- up: string[];
11
- down: string[];
12
- },
13
- ): string;
4
+ /**
5
+ * @inheritDoc
6
+ */
7
+ generateMigrationFile(className: string, diff: {
8
+ up: string[];
9
+ down: string[];
10
+ }): string;
14
11
  }
@@ -1,26 +1,26 @@
1
1
  import { MigrationGenerator } from './MigrationGenerator.js';
2
2
  /** Generates MongoDB migration files in CommonJS JavaScript format. */
3
3
  export class JSMigrationGenerator extends MigrationGenerator {
4
- /**
5
- * @inheritDoc
6
- */
7
- generateMigrationFile(className, diff) {
8
- let ret = `'use strict';\n`;
9
- ret += `Object.defineProperty(exports, '__esModule', { value: true });\n`;
10
- ret += `const { Migration } = require('@mikro-orm/migrations-mongodb');\n\n`;
11
- ret += `class ${className} extends Migration {\n\n`;
12
- ret += ` async up() {\n`;
13
- /* v8 ignore next */
14
- diff.up.forEach(sql => (ret += this.createStatement(sql, 4)));
15
- ret += ` }\n\n`;
16
- /* v8 ignore next */
17
- if (diff.down.length > 0) {
18
- ret += ` async down() {\n`;
19
- diff.down.forEach(sql => (ret += this.createStatement(sql, 4)));
20
- ret += ` }\n\n`;
4
+ /**
5
+ * @inheritDoc
6
+ */
7
+ generateMigrationFile(className, diff) {
8
+ let ret = `'use strict';\n`;
9
+ ret += `Object.defineProperty(exports, '__esModule', { value: true });\n`;
10
+ ret += `const { Migration } = require('@mikro-orm/migrations-mongodb');\n\n`;
11
+ ret += `class ${className} extends Migration {\n\n`;
12
+ ret += ` async up() {\n`;
13
+ /* v8 ignore next */
14
+ diff.up.forEach(sql => (ret += this.createStatement(sql, 4)));
15
+ ret += ` }\n\n`;
16
+ /* v8 ignore next */
17
+ if (diff.down.length > 0) {
18
+ ret += ` async down() {\n`;
19
+ diff.down.forEach(sql => (ret += this.createStatement(sql, 4)));
20
+ ret += ` }\n\n`;
21
+ }
22
+ ret += `}\n`;
23
+ ret += `exports.${className} = ${className};\n`;
24
+ return ret;
21
25
  }
22
- ret += `}\n`;
23
- ret += `exports.${className} = ${className};\n`;
24
- return ret;
25
- }
26
26
  }
package/Migration.d.ts CHANGED
@@ -3,15 +3,15 @@ import type { MongoDriver } from '@mikro-orm/mongodb';
3
3
  import type { Collection, ClientSession, Document, Db } from 'mongodb';
4
4
  /** Base class for MongoDB migrations. Extend this class and implement `up()` (and optionally `down()`). */
5
5
  export declare abstract class Migration {
6
- protected readonly driver: MongoDriver;
7
- protected readonly config: Configuration;
8
- protected ctx?: Transaction<ClientSession>;
9
- constructor(driver: MongoDriver, config: Configuration);
10
- abstract up(): Promise<void>;
11
- down(): Promise<void>;
12
- isTransactional(): boolean;
13
- reset(): void;
14
- setTransactionContext(ctx: Transaction): void;
15
- getCollection<T extends Document>(entityOrCollectionName: EntityName<T> | string): Collection<T>;
16
- getDb(): Db;
6
+ protected readonly driver: MongoDriver;
7
+ protected readonly config: Configuration;
8
+ protected ctx?: Transaction<ClientSession>;
9
+ constructor(driver: MongoDriver, config: Configuration);
10
+ abstract up(): Promise<void>;
11
+ down(): Promise<void>;
12
+ isTransactional(): boolean;
13
+ reset(): void;
14
+ setTransactionContext(ctx: Transaction): void;
15
+ getCollection<T extends Document>(entityOrCollectionName: EntityName<T> | string): Collection<T>;
16
+ getDb(): Db;
17
17
  }
package/Migration.js CHANGED
@@ -1,28 +1,28 @@
1
1
  /** Base class for MongoDB migrations. Extend this class and implement `up()` (and optionally `down()`). */
2
2
  export class Migration {
3
- driver;
4
- config;
5
- ctx;
6
- constructor(driver, config) {
7
- this.driver = driver;
8
- this.config = config;
9
- }
10
- async down() {
11
- throw new Error('This migration cannot be reverted');
12
- }
13
- isTransactional() {
14
- return true;
15
- }
16
- reset() {
17
- this.ctx = undefined;
18
- }
19
- setTransactionContext(ctx) {
20
- this.ctx = ctx;
21
- }
22
- getCollection(entityOrCollectionName) {
23
- return this.driver.getConnection().getCollection(entityOrCollectionName);
24
- }
25
- getDb() {
26
- return this.driver.getConnection().getDb();
27
- }
3
+ driver;
4
+ config;
5
+ ctx;
6
+ constructor(driver, config) {
7
+ this.driver = driver;
8
+ this.config = config;
9
+ }
10
+ async down() {
11
+ throw new Error('This migration cannot be reverted');
12
+ }
13
+ isTransactional() {
14
+ return true;
15
+ }
16
+ reset() {
17
+ this.ctx = undefined;
18
+ }
19
+ setTransactionContext(ctx) {
20
+ this.ctx = ctx;
21
+ }
22
+ getCollection(entityOrCollectionName) {
23
+ return this.driver.getConnection().getCollection(entityOrCollectionName);
24
+ }
25
+ getDb() {
26
+ return this.driver.getConnection().getDb();
27
+ }
28
28
  }
@@ -1,37 +1,25 @@
1
- import {
2
- type IMigrationGenerator,
3
- type MaybePromise,
4
- type MigrationsOptions,
5
- type NamingStrategy,
6
- } from '@mikro-orm/core';
1
+ import { type IMigrationGenerator, type MaybePromise, type MigrationsOptions, type NamingStrategy } from '@mikro-orm/core';
7
2
  import type { MongoDriver } from '@mikro-orm/mongodb';
8
3
  /** Base class for generating MongoDB migration source files. */
9
4
  export declare abstract class MigrationGenerator implements IMigrationGenerator {
10
- protected readonly driver: MongoDriver;
11
- protected readonly namingStrategy: NamingStrategy;
12
- protected readonly options: MigrationsOptions;
13
- constructor(driver: MongoDriver, namingStrategy: NamingStrategy, options: MigrationsOptions);
14
- /**
15
- * @inheritDoc
16
- */
17
- generate(
18
- diff: {
19
- up: string[];
20
- down: string[];
21
- },
22
- path?: string,
23
- name?: string,
24
- ): Promise<[string, string]>;
25
- /** @inheritDoc */
26
- createStatement(query: string, padLeft: number): string;
27
- /**
28
- * @inheritDoc
29
- */
30
- abstract generateMigrationFile(
31
- className: string,
32
- diff: {
33
- up: string[];
34
- down: string[];
35
- },
36
- ): MaybePromise<string>;
5
+ protected readonly driver: MongoDriver;
6
+ protected readonly namingStrategy: NamingStrategy;
7
+ protected readonly options: MigrationsOptions;
8
+ constructor(driver: MongoDriver, namingStrategy: NamingStrategy, options: MigrationsOptions);
9
+ /**
10
+ * @inheritDoc
11
+ */
12
+ generate(diff: {
13
+ up: string[];
14
+ down: string[];
15
+ }, path?: string, name?: string): Promise<[string, string]>;
16
+ /** @inheritDoc */
17
+ createStatement(query: string, padLeft: number): string;
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ abstract generateMigrationFile(className: string, diff: {
22
+ up: string[];
23
+ down: string[];
24
+ }): MaybePromise<string>;
37
25
  }
@@ -1,36 +1,36 @@
1
1
  /** Base class for generating MongoDB migration source files. */
2
2
  export class MigrationGenerator {
3
- driver;
4
- namingStrategy;
5
- options;
6
- constructor(driver, namingStrategy, options) {
7
- this.driver = driver;
8
- this.namingStrategy = namingStrategy;
9
- this.options = options;
10
- }
11
- /**
12
- * @inheritDoc
13
- */
14
- async generate(diff, path, name) {
15
- const { fs } = await import('@mikro-orm/core/fs-utils');
3
+ driver;
4
+ namingStrategy;
5
+ options;
6
+ constructor(driver, namingStrategy, options) {
7
+ this.driver = driver;
8
+ this.namingStrategy = namingStrategy;
9
+ this.options = options;
10
+ }
11
+ /**
12
+ * @inheritDoc
13
+ */
14
+ async generate(diff, path, name) {
15
+ const { fs } = await import('@mikro-orm/core/fs-utils');
16
+ /* v8 ignore next */
17
+ const defaultPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path;
18
+ path = fs.normalizePath(this.driver.config.get('baseDir'), path ?? defaultPath);
19
+ fs.ensureDir(path);
20
+ const timestamp = new Date().toISOString().replace(/[-T:]|\.\d{3}z$/gi, '');
21
+ const className = this.namingStrategy.classToMigrationName(timestamp, name);
22
+ const fileName = `${this.options.fileName(timestamp, name)}.${this.options.emit}`;
23
+ const ret = await this.generateMigrationFile(className, diff);
24
+ await fs.writeFile(path + '/' + fileName, ret, { flush: true });
25
+ return [ret, fileName];
26
+ }
27
+ /** @inheritDoc */
16
28
  /* v8 ignore next */
17
- const defaultPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path;
18
- path = fs.normalizePath(this.driver.config.get('baseDir'), path ?? defaultPath);
19
- fs.ensureDir(path);
20
- const timestamp = new Date().toISOString().replace(/[-T:]|\.\d{3}z$/gi, '');
21
- const className = this.namingStrategy.classToMigrationName(timestamp, name);
22
- const fileName = `${this.options.fileName(timestamp, name)}.${this.options.emit}`;
23
- const ret = await this.generateMigrationFile(className, diff);
24
- await fs.writeFile(path + '/' + fileName, ret, { flush: true });
25
- return [ret, fileName];
26
- }
27
- /** @inheritDoc */
28
- /* v8 ignore next */
29
- createStatement(query, padLeft) {
30
- if (query) {
31
- const padding = ' '.repeat(padLeft);
32
- return `${padding}console.log('${query}');\n`;
29
+ createStatement(query, padLeft) {
30
+ if (query) {
31
+ const padding = ' '.repeat(padLeft);
32
+ return `${padding}console.log('${query}');\n`;
33
+ }
34
+ return '\n';
33
35
  }
34
- return '\n';
35
- }
36
36
  }
@@ -3,12 +3,12 @@ import type { MongoDriver } from '@mikro-orm/mongodb';
3
3
  import type { Migration } from './Migration.js';
4
4
  /** Executes individual MongoDB migration files within optional transaction contexts. */
5
5
  export declare class MigrationRunner {
6
- protected readonly driver: MongoDriver;
7
- protected readonly options: MigrationsOptions;
8
- private readonly connection;
9
- private masterTransaction?;
10
- constructor(driver: MongoDriver, options: MigrationsOptions);
11
- run(migration: Migration, method: 'up' | 'down'): Promise<void>;
12
- setMasterMigration(trx: Transaction): void;
13
- unsetMasterMigration(): void;
6
+ protected readonly driver: MongoDriver;
7
+ protected readonly options: MigrationsOptions;
8
+ private readonly connection;
9
+ private masterTransaction?;
10
+ constructor(driver: MongoDriver, options: MigrationsOptions);
11
+ run(migration: Migration, method: 'up' | 'down'): Promise<void>;
12
+ setMasterMigration(trx: Transaction): void;
13
+ unsetMasterMigration(): void;
14
14
  }
@@ -1,35 +1,34 @@
1
1
  /** Executes individual MongoDB migration files within optional transaction contexts. */
2
2
  export class MigrationRunner {
3
- driver;
4
- options;
5
- connection;
6
- masterTransaction;
7
- constructor(driver, options) {
8
- this.driver = driver;
9
- this.options = options;
10
- this.connection = this.driver.getConnection();
11
- }
12
- async run(migration, method) {
13
- migration.reset();
14
- if (!this.options.transactional || !migration.isTransactional()) {
15
- await migration[method]();
16
- } else if (this.masterTransaction) {
17
- migration.setTransactionContext(this.masterTransaction);
18
- await migration[method]();
19
- } else {
20
- await this.connection.transactional(
21
- async tx => {
22
- migration.setTransactionContext(tx);
23
- await migration[method]();
24
- },
25
- { ctx: this.masterTransaction },
26
- );
3
+ driver;
4
+ options;
5
+ connection;
6
+ masterTransaction;
7
+ constructor(driver, options) {
8
+ this.driver = driver;
9
+ this.options = options;
10
+ this.connection = this.driver.getConnection();
11
+ }
12
+ async run(migration, method) {
13
+ migration.reset();
14
+ if (!this.options.transactional || !migration.isTransactional()) {
15
+ await migration[method]();
16
+ }
17
+ else if (this.masterTransaction) {
18
+ migration.setTransactionContext(this.masterTransaction);
19
+ await migration[method]();
20
+ }
21
+ else {
22
+ await this.connection.transactional(async (tx) => {
23
+ migration.setTransactionContext(tx);
24
+ await migration[method]();
25
+ }, { ctx: this.masterTransaction });
26
+ }
27
+ }
28
+ setMasterMigration(trx) {
29
+ this.masterTransaction = trx;
30
+ }
31
+ unsetMasterMigration() {
32
+ delete this.masterTransaction;
27
33
  }
28
- }
29
- setMasterMigration(trx) {
30
- this.masterTransaction = trx;
31
- }
32
- unsetMasterMigration() {
33
- delete this.masterTransaction;
34
- }
35
34
  }
@@ -3,22 +3,26 @@ import type { MongoDriver } from '@mikro-orm/mongodb';
3
3
  import type { MigrationRow } from './typings.js';
4
4
  /** Tracks executed MongoDB migrations in a collection. */
5
5
  export declare class MigrationStorage {
6
- protected readonly driver: MongoDriver;
7
- protected readonly options: MigrationsOptions;
8
- private masterTransaction?;
9
- constructor(driver: MongoDriver, options: MigrationsOptions);
10
- executed(): Promise<string[]>;
11
- logMigration(params: { name: string }): Promise<void>;
12
- unlogMigration(params: { name: string }): Promise<void>;
13
- getExecutedMigrations(): Promise<MigrationRow[]>;
14
- setMasterMigration(trx: Transaction): void;
15
- unsetMasterMigration(): void;
16
- /**
17
- * @internal
18
- */
19
- getMigrationName(name: string): string;
20
- /**
21
- * @internal
22
- */
23
- getEntityDefinition(): EntitySchema;
6
+ protected readonly driver: MongoDriver;
7
+ protected readonly options: MigrationsOptions;
8
+ private masterTransaction?;
9
+ constructor(driver: MongoDriver, options: MigrationsOptions);
10
+ executed(): Promise<string[]>;
11
+ logMigration(params: {
12
+ name: string;
13
+ }): Promise<void>;
14
+ unlogMigration(params: {
15
+ name: string;
16
+ }): Promise<void>;
17
+ getExecutedMigrations(): Promise<MigrationRow[]>;
18
+ setMasterMigration(trx: Transaction): void;
19
+ unsetMasterMigration(): void;
20
+ /**
21
+ * @internal
22
+ */
23
+ getMigrationName(name: string): string;
24
+ /**
25
+ * @internal
26
+ */
27
+ getEntityDefinition(): EntitySchema;
24
28
  }
@@ -1,61 +1,57 @@
1
- import { defineEntity, p } from '@mikro-orm/core';
1
+ import { defineEntity, p, } from '@mikro-orm/core';
2
2
  /** Tracks executed MongoDB migrations in a collection. */
3
3
  export class MigrationStorage {
4
- driver;
5
- options;
6
- masterTransaction;
7
- constructor(driver, options) {
8
- this.driver = driver;
9
- this.options = options;
10
- }
11
- async executed() {
12
- const migrations = await this.getExecutedMigrations();
13
- return migrations.map(({ name }) => this.getMigrationName(name));
14
- }
15
- async logMigration(params) {
16
- const name = this.getMigrationName(params.name);
17
- const entity = this.getEntityDefinition();
18
- await this.driver.nativeInsert(entity, { name, executed_at: new Date() }, { ctx: this.masterTransaction });
19
- }
20
- async unlogMigration(params) {
21
- const withoutExt = this.getMigrationName(params.name);
22
- const entity = this.getEntityDefinition();
23
- await this.driver.nativeDelete(
24
- entity,
25
- { name: { $in: [params.name, withoutExt] } },
26
- { ctx: this.masterTransaction },
27
- );
28
- }
29
- async getExecutedMigrations() {
30
- const entity = this.getEntityDefinition();
31
- return this.driver.find(entity, {}, { ctx: this.masterTransaction, orderBy: { _id: 'asc' } });
32
- }
33
- setMasterMigration(trx) {
34
- this.masterTransaction = trx;
35
- }
36
- unsetMasterMigration() {
37
- delete this.masterTransaction;
38
- }
39
- /**
40
- * @internal
41
- */
42
- getMigrationName(name) {
43
- return name.replace(/\.[jt]s$/, '');
44
- }
45
- /**
46
- * @internal
47
- */
48
- getEntityDefinition() {
49
- const entity = defineEntity({
50
- name: 'Migration',
51
- tableName: this.options.tableName,
52
- properties: {
53
- id: p.integer().primary().fieldNames('id'),
54
- name: p.string().fieldNames('name'),
55
- executedAt: p.datetime().defaultRaw('current_timestamp').fieldNames('executed_at'),
56
- },
57
- }).init();
58
- entity.meta.sync();
59
- return entity;
60
- }
4
+ driver;
5
+ options;
6
+ masterTransaction;
7
+ constructor(driver, options) {
8
+ this.driver = driver;
9
+ this.options = options;
10
+ }
11
+ async executed() {
12
+ const migrations = await this.getExecutedMigrations();
13
+ return migrations.map(({ name }) => this.getMigrationName(name));
14
+ }
15
+ async logMigration(params) {
16
+ const name = this.getMigrationName(params.name);
17
+ const entity = this.getEntityDefinition();
18
+ await this.driver.nativeInsert(entity, { name, executed_at: new Date() }, { ctx: this.masterTransaction });
19
+ }
20
+ async unlogMigration(params) {
21
+ const withoutExt = this.getMigrationName(params.name);
22
+ const entity = this.getEntityDefinition();
23
+ await this.driver.nativeDelete(entity, { name: { $in: [params.name, withoutExt] } }, { ctx: this.masterTransaction });
24
+ }
25
+ async getExecutedMigrations() {
26
+ const entity = this.getEntityDefinition();
27
+ return this.driver.find(entity, {}, { ctx: this.masterTransaction, orderBy: { _id: 'asc' } });
28
+ }
29
+ setMasterMigration(trx) {
30
+ this.masterTransaction = trx;
31
+ }
32
+ unsetMasterMigration() {
33
+ delete this.masterTransaction;
34
+ }
35
+ /**
36
+ * @internal
37
+ */
38
+ getMigrationName(name) {
39
+ return name.replace(/\.[jt]s$/, '');
40
+ }
41
+ /**
42
+ * @internal
43
+ */
44
+ getEntityDefinition() {
45
+ const entity = defineEntity({
46
+ name: 'Migration',
47
+ tableName: this.options.tableName,
48
+ properties: {
49
+ id: p.integer().primary().fieldNames('id'),
50
+ name: p.string().fieldNames('name'),
51
+ executedAt: p.datetime().defaultRaw('current_timestamp').fieldNames('executed_at'),
52
+ },
53
+ }).init();
54
+ entity.meta.sync();
55
+ return entity;
56
+ }
61
57
  }
package/Migrator.d.ts CHANGED
@@ -5,19 +5,19 @@ import { MigrationStorage } from './MigrationStorage.js';
5
5
  import type { MigrationResult } from './typings.js';
6
6
  /** Manages MongoDB migrations: creation, execution, and rollback. */
7
7
  export declare class Migrator extends AbstractMigrator<MongoDriver> {
8
- static register(orm: MikroORM): void;
9
- protected createRunner(): IMigrationRunner;
10
- protected createStorage(): IMigratorStorage;
11
- protected getDefaultGenerator(): IMigrationGenerator;
12
- /**
13
- * @inheritDoc
14
- */
15
- create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
16
- /** @inheritDoc */
17
- checkSchema(): Promise<boolean>;
18
- /**
19
- * @inheritDoc
20
- */
21
- createInitial(path?: string): Promise<MigrationResult>;
22
- getStorage(): MigrationStorage;
8
+ static register(orm: MikroORM): void;
9
+ protected createRunner(): IMigrationRunner;
10
+ protected createStorage(): IMigratorStorage;
11
+ protected getDefaultGenerator(): IMigrationGenerator;
12
+ /**
13
+ * @inheritDoc
14
+ */
15
+ create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
16
+ /** @inheritDoc */
17
+ checkSchema(): Promise<boolean>;
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ createInitial(path?: string): Promise<MigrationResult>;
22
+ getStorage(): MigrationStorage;
23
23
  }
package/Migrator.js CHANGED
@@ -5,47 +5,47 @@ import { TSMigrationGenerator } from './TSMigrationGenerator.js';
5
5
  import { JSMigrationGenerator } from './JSMigrationGenerator.js';
6
6
  /** Manages MongoDB migrations: creation, execution, and rollback. */
7
7
  export class Migrator extends AbstractMigrator {
8
- static register(orm) {
9
- orm.config.registerExtension('@mikro-orm/migrator', () => new Migrator(orm.em));
10
- }
11
- createRunner() {
12
- return new MigrationRunner(this.driver, this.options);
13
- }
14
- createStorage() {
15
- return new MigrationStorage(this.driver, this.options);
16
- }
17
- getDefaultGenerator() {
8
+ static register(orm) {
9
+ orm.config.registerExtension('@mikro-orm/migrator', () => new Migrator(orm.em));
10
+ }
11
+ createRunner() {
12
+ return new MigrationRunner(this.driver, this.options);
13
+ }
14
+ createStorage() {
15
+ return new MigrationStorage(this.driver, this.options);
16
+ }
17
+ getDefaultGenerator() {
18
+ /* v8 ignore next */
19
+ if (this.options.emit === 'js' || this.options.emit === 'cjs') {
20
+ return new JSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
21
+ }
22
+ return new TSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
23
+ }
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ async create(path, blank = false, initial = false, name) {
28
+ await this.init();
29
+ const diff = { up: [], down: [] };
30
+ const migration = await this.generator.generate(diff, path, name);
31
+ return {
32
+ fileName: migration[1],
33
+ code: migration[0],
34
+ diff,
35
+ };
36
+ }
37
+ /** @inheritDoc */
18
38
  /* v8 ignore next */
19
- if (this.options.emit === 'js' || this.options.emit === 'cjs') {
20
- return new JSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
21
- }
22
- return new TSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
23
- }
24
- /**
25
- * @inheritDoc
26
- */
27
- async create(path, blank = false, initial = false, name) {
28
- await this.init();
29
- const diff = { up: [], down: [] };
30
- const migration = await this.generator.generate(diff, path, name);
31
- return {
32
- fileName: migration[1],
33
- code: migration[0],
34
- diff,
35
- };
36
- }
37
- /** @inheritDoc */
38
- /* v8 ignore next */
39
- async checkSchema() {
40
- return true;
41
- }
42
- /**
43
- * @inheritDoc
44
- */
45
- async createInitial(path) {
46
- return this.create(path);
47
- }
48
- getStorage() {
49
- return this.storage;
50
- }
39
+ async checkSchema() {
40
+ return true;
41
+ }
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ async createInitial(path) {
46
+ return this.create(path);
47
+ }
48
+ getStorage() {
49
+ return this.storage;
50
+ }
51
51
  }
package/README.md CHANGED
@@ -133,7 +133,7 @@ const author = await em.findOneOrFail(Author, 1, {
133
133
  populate: ['books'],
134
134
  });
135
135
  author.name = 'Jon Snow II';
136
- author.books.getItems().forEach(book => (book.title += ' (2nd ed.)'));
136
+ author.books.getItems().forEach(book => book.title += ' (2nd ed.)');
137
137
  author.books.add(orm.em.create(Book, { title: 'New Book', author }));
138
138
 
139
139
  // Flush computes change sets and executes them in a single transaction
@@ -1,14 +1,11 @@
1
1
  import { MigrationGenerator } from './MigrationGenerator.js';
2
2
  /** Generates MongoDB migration files in TypeScript format. */
3
3
  export declare class TSMigrationGenerator extends MigrationGenerator {
4
- /**
5
- * @inheritDoc
6
- */
7
- generateMigrationFile(
8
- className: string,
9
- diff: {
10
- up: string[];
11
- down: string[];
12
- },
13
- ): string;
4
+ /**
5
+ * @inheritDoc
6
+ */
7
+ generateMigrationFile(className: string, diff: {
8
+ up: string[];
9
+ down: string[];
10
+ }): string;
14
11
  }
@@ -1,23 +1,23 @@
1
1
  import { MigrationGenerator } from './MigrationGenerator.js';
2
2
  /** Generates MongoDB migration files in TypeScript format. */
3
3
  export class TSMigrationGenerator extends MigrationGenerator {
4
- /**
5
- * @inheritDoc
6
- */
7
- generateMigrationFile(className, diff) {
8
- let ret = `import { Migration } from '@mikro-orm/migrations-mongodb';\n\n`;
9
- ret += `export class ${className} extends Migration {\n\n`;
10
- ret += ` async up(): Promise<void> {\n`;
11
- /* v8 ignore next */
12
- diff.up.forEach(sql => (ret += this.createStatement(sql, 4)));
13
- ret += ` }\n\n`;
14
- /* v8 ignore next */
15
- if (diff.down.length > 0) {
16
- ret += ` async down(): Promise<void> {\n`;
17
- diff.down.forEach(sql => (ret += this.createStatement(sql, 4)));
18
- ret += ` }\n\n`;
4
+ /**
5
+ * @inheritDoc
6
+ */
7
+ generateMigrationFile(className, diff) {
8
+ let ret = `import { Migration } from '@mikro-orm/migrations-mongodb';\n\n`;
9
+ ret += `export class ${className} extends Migration {\n\n`;
10
+ ret += ` async up(): Promise<void> {\n`;
11
+ /* v8 ignore next */
12
+ diff.up.forEach(sql => (ret += this.createStatement(sql, 4)));
13
+ ret += ` }\n\n`;
14
+ /* v8 ignore next */
15
+ if (diff.down.length > 0) {
16
+ ret += ` async down(): Promise<void> {\n`;
17
+ diff.down.forEach(sql => (ret += this.createStatement(sql, 4)));
18
+ ret += ` }\n\n`;
19
+ }
20
+ ret += `}\n`;
21
+ return ret;
19
22
  }
20
- ret += `}\n`;
21
- return ret;
22
- }
23
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/migrations-mongodb",
3
- "version": "7.0.4",
3
+ "version": "7.0.5-dev.1",
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
  "keywords": [
6
6
  "data-mapper",
@@ -47,14 +47,14 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "@mikro-orm/mongodb": "7.0.4",
50
+ "@mikro-orm/mongodb": "7.0.5-dev.1",
51
51
  "mongodb": "7.1.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@mikro-orm/core": "^7.0.4"
55
55
  },
56
56
  "peerDependencies": {
57
- "@mikro-orm/core": "7.0.4"
57
+ "@mikro-orm/core": "7.0.5-dev.1"
58
58
  },
59
59
  "engines": {
60
60
  "node": ">= 22.17.0"