@mikro-orm/migrations-mongodb 7.0.0-dev.1 → 7.0.0-dev.100

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,4 +1,4 @@
1
- import { MigrationGenerator } from './MigrationGenerator';
1
+ import { MigrationGenerator } from './MigrationGenerator.js';
2
2
  export declare class JSMigrationGenerator extends MigrationGenerator {
3
3
  /**
4
4
  * @inheritDoc
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JSMigrationGenerator = void 0;
4
- const MigrationGenerator_1 = require("./MigrationGenerator");
5
- class JSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
1
+ import { MigrationGenerator } from './MigrationGenerator.js';
2
+ export class JSMigrationGenerator extends MigrationGenerator {
6
3
  /**
7
4
  * @inheritDoc
8
5
  */
@@ -12,10 +9,10 @@ class JSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
12
9
  ret += `const { Migration } = require('@mikro-orm/migrations-mongodb');\n\n`;
13
10
  ret += `class ${className} extends Migration {\n\n`;
14
11
  ret += ` async up() {\n`;
15
- /* istanbul ignore next */
12
+ /* v8 ignore next */
16
13
  diff.up.forEach(sql => ret += this.createStatement(sql, 4));
17
14
  ret += ` }\n\n`;
18
- /* istanbul ignore next */
15
+ /* v8 ignore next */
19
16
  if (diff.down.length > 0) {
20
17
  ret += ` async down() {\n`;
21
18
  diff.down.forEach(sql => ret += this.createStatement(sql, 4));
@@ -26,4 +23,3 @@ class JSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
26
23
  return ret;
27
24
  }
28
25
  }
29
- exports.JSMigrationGenerator = JSMigrationGenerator;
package/Migration.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Migration = void 0;
4
- class Migration {
1
+ export class Migration {
5
2
  driver;
6
3
  config;
7
4
  ctx;
@@ -25,4 +22,3 @@ class Migration {
25
22
  return this.driver.getConnection().getCollection(entityName);
26
23
  }
27
24
  }
28
- exports.Migration = Migration;
@@ -12,9 +12,7 @@ export declare abstract class MigrationGenerator implements IMigrationGenerator
12
12
  up: string[];
13
13
  down: string[];
14
14
  }, path?: string, name?: string): Promise<[string, string]>;
15
- /**
16
- * @inheritDoc
17
- */
15
+ /** @inheritDoc */
18
16
  createStatement(query: string, padLeft: number): string;
19
17
  /**
20
18
  * @inheritDoc
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationGenerator = void 0;
4
- const core_1 = require("@mikro-orm/core");
5
- const fs_extra_1 = require("fs-extra");
6
- /* istanbul ignore next */
7
- class MigrationGenerator {
1
+ import { Utils, } from '@mikro-orm/core';
2
+ import { fs } from '@mikro-orm/core/fs-utils';
3
+ import { writeFile } from 'node:fs/promises';
4
+ export class MigrationGenerator {
8
5
  driver;
9
6
  namingStrategy;
10
7
  options;
@@ -17,20 +14,19 @@ class MigrationGenerator {
17
14
  * @inheritDoc
18
15
  */
19
16
  async generate(diff, path, name) {
20
- /* istanbul ignore next */
17
+ /* v8 ignore next */
21
18
  const defaultPath = this.options.emit === 'ts' && this.options.pathTs ? this.options.pathTs : this.options.path;
22
- path = core_1.Utils.normalizePath(this.driver.config.get('baseDir'), path ?? defaultPath);
23
- await (0, fs_extra_1.ensureDir)(path);
19
+ path = Utils.normalizePath(this.driver.config.get('baseDir'), path ?? defaultPath);
20
+ fs.ensureDir(path);
24
21
  const timestamp = new Date().toISOString().replace(/[-T:]|\.\d{3}z$/ig, '');
25
22
  const className = this.namingStrategy.classToMigrationName(timestamp, name);
26
23
  const fileName = `${this.options.fileName(timestamp, name)}.${this.options.emit}`;
27
24
  const ret = await this.generateMigrationFile(className, diff);
28
- await (0, fs_extra_1.writeFile)(path + '/' + fileName, ret, { flush: true });
25
+ await writeFile(path + '/' + fileName, ret, { flush: true });
29
26
  return [ret, fileName];
30
27
  }
31
- /**
32
- * @inheritDoc
33
- */
28
+ /** @inheritDoc */
29
+ /* v8 ignore next */
34
30
  createStatement(query, padLeft) {
35
31
  if (query) {
36
32
  const padding = ' '.repeat(padLeft);
@@ -39,4 +35,3 @@ class MigrationGenerator {
39
35
  return '\n';
40
36
  }
41
37
  }
42
- exports.MigrationGenerator = MigrationGenerator;
@@ -1,6 +1,6 @@
1
1
  import type { MigrationsOptions, Transaction } from '@mikro-orm/core';
2
2
  import type { MongoDriver } from '@mikro-orm/mongodb';
3
- import type { Migration } from './Migration';
3
+ import type { Migration } from './Migration.js';
4
4
  export declare class MigrationRunner {
5
5
  protected readonly driver: MongoDriver;
6
6
  protected readonly options: MigrationsOptions;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationRunner = void 0;
4
- class MigrationRunner {
1
+ export class MigrationRunner {
5
2
  driver;
6
3
  options;
7
4
  connection;
@@ -34,4 +31,3 @@ class MigrationRunner {
34
31
  delete this.masterTransaction;
35
32
  }
36
33
  }
37
- exports.MigrationRunner = MigrationRunner;
@@ -1,7 +1,7 @@
1
1
  import type { MigrationsOptions, Transaction } from '@mikro-orm/core';
2
2
  import type { MongoDriver } from '@mikro-orm/mongodb';
3
3
  import type { MigrationParams, UmzugStorage } from 'umzug';
4
- import type { MigrationRow } from './typings';
4
+ import type { MigrationRow } from './typings.js';
5
5
  export declare class MigrationStorage implements UmzugStorage {
6
6
  protected readonly driver: MongoDriver;
7
7
  protected readonly options: MigrationsOptions;
@@ -1,41 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.MigrationStorage = void 0;
37
- const path = __importStar(require("node:path"));
38
- class MigrationStorage {
1
+ import { parse } from 'node:path';
2
+ export class MigrationStorage {
39
3
  driver;
40
4
  options;
41
5
  masterTransaction;
@@ -71,7 +35,7 @@ class MigrationStorage {
71
35
  * @internal
72
36
  */
73
37
  getMigrationName(name) {
74
- const parsedName = path.parse(name);
38
+ const parsedName = parse(name);
75
39
  if (['.js', '.ts'].includes(parsedName.ext)) {
76
40
  // strip extension
77
41
  return parsedName.name;
@@ -79,4 +43,3 @@ class MigrationStorage {
79
43
  return name;
80
44
  }
81
45
  }
82
- exports.MigrationStorage = MigrationStorage;
package/Migrator.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { type MigrationParams, type RunnableMigration } from 'umzug';
2
- import { type Constructor, type IMigrator, type MikroORM, type MigratorEvent, type MaybePromise } from '@mikro-orm/core';
2
+ import { type Constructor, type IMigrator, type MaybePromise, type MigratorEvent, type MikroORM } from '@mikro-orm/core';
3
3
  import type { EntityManager } from '@mikro-orm/mongodb';
4
- import type { Migration } from './Migration';
5
- import { MigrationStorage } from './MigrationStorage';
6
- import type { MigrateOptions, MigrationResult, MigrationRow, UmzugMigration } from './typings';
4
+ import type { Migration } from './Migration.js';
5
+ import { MigrationStorage } from './MigrationStorage.js';
6
+ import type { MigrateOptions, MigrationResult, MigrationRow, UmzugMigration } from './typings.js';
7
7
  export declare class Migrator implements IMigrator {
8
8
  private readonly em;
9
9
  private umzug;
@@ -17,17 +17,24 @@ export declare class Migrator implements IMigrator {
17
17
  constructor(em: EntityManager);
18
18
  static register(orm: MikroORM): void;
19
19
  /**
20
- * @inheritDoc
20
+ * Checks if `src` folder exists, it so, tries to adjust the migrations and seeders paths automatically to use it.
21
+ * If there is a `dist` or `build` folder, it will be used for the JS variant (`path` option), while the `src` folder will be
22
+ * used for the TS variant (`pathTs` option).
23
+ *
24
+ * If the default folder exists (e.g. `/migrations`), the config will respect that, so this auto-detection should not
25
+ * break existing projects, only help with the new ones.
21
26
  */
22
- createMigration(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
27
+ private detectSourceFolder;
23
28
  /**
24
29
  * @inheritDoc
25
30
  */
26
- checkMigrationNeeded(): Promise<boolean>;
31
+ create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
32
+ /** @inheritDoc */
33
+ checkSchema(): Promise<boolean>;
27
34
  /**
28
35
  * @inheritDoc
29
36
  */
30
- createInitialMigration(path?: string): Promise<MigrationResult>;
37
+ createInitial(path?: string): Promise<MigrationResult>;
31
38
  /**
32
39
  * @inheritDoc
33
40
  */
@@ -40,11 +47,11 @@ export declare class Migrator implements IMigrator {
40
47
  /**
41
48
  * @inheritDoc
42
49
  */
43
- getExecutedMigrations(): Promise<MigrationRow[]>;
50
+ getExecuted(): Promise<MigrationRow[]>;
44
51
  /**
45
52
  * @inheritDoc
46
53
  */
47
- getPendingMigrations(): Promise<UmzugMigration[]>;
54
+ getPending(): Promise<UmzugMigration[]>;
48
55
  /**
49
56
  * @inheritDoc
50
57
  */
package/Migrator.js CHANGED
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Migrator = void 0;
4
- const umzug_1 = require("umzug");
5
- const node_path_1 = require("node:path");
6
- const fs_extra_1 = require("fs-extra");
7
- const core_1 = require("@mikro-orm/core");
8
- const MigrationRunner_1 = require("./MigrationRunner");
9
- const MigrationStorage_1 = require("./MigrationStorage");
10
- const TSMigrationGenerator_1 = require("./TSMigrationGenerator");
11
- const JSMigrationGenerator_1 = require("./JSMigrationGenerator");
12
- class Migrator {
1
+ import { Umzug, } from 'umzug';
2
+ import { join } from 'node:path';
3
+ import { Utils, } from '@mikro-orm/core';
4
+ import { fs } from '@mikro-orm/core/fs-utils';
5
+ import { MigrationRunner } from './MigrationRunner.js';
6
+ import { MigrationStorage } from './MigrationStorage.js';
7
+ import { TSMigrationGenerator } from './TSMigrationGenerator.js';
8
+ import { JSMigrationGenerator } from './JSMigrationGenerator.js';
9
+ export class Migrator {
13
10
  em;
14
11
  umzug;
15
12
  runner;
@@ -24,19 +21,47 @@ class Migrator {
24
21
  this.driver = this.em.getDriver();
25
22
  this.config = this.em.config;
26
23
  this.options = this.config.get('migrations');
27
- /* istanbul ignore next */
28
- const key = (this.config.get('preferTs', core_1.Utils.detectTsNode()) && this.options.pathTs) ? 'pathTs' : 'path';
29
- this.absolutePath = core_1.Utils.absolutePath(this.options[key], this.config.get('baseDir'));
24
+ this.detectSourceFolder();
25
+ /* v8 ignore next */
26
+ const key = (this.config.get('preferTs', Utils.detectTypeScriptSupport()) && this.options.pathTs) ? 'pathTs' : 'path';
27
+ this.absolutePath = Utils.absolutePath(this.options[key], this.config.get('baseDir'));
30
28
  this.createUmzug();
31
29
  }
32
30
  static register(orm) {
33
31
  orm.config.registerExtension('@mikro-orm/migrator', () => new Migrator(orm.em));
34
32
  }
33
+ /**
34
+ * Checks if `src` folder exists, it so, tries to adjust the migrations and seeders paths automatically to use it.
35
+ * If there is a `dist` or `build` folder, it will be used for the JS variant (`path` option), while the `src` folder will be
36
+ * used for the TS variant (`pathTs` option).
37
+ *
38
+ * If the default folder exists (e.g. `/migrations`), the config will respect that, so this auto-detection should not
39
+ * break existing projects, only help with the new ones.
40
+ */
41
+ detectSourceFolder() {
42
+ const baseDir = this.config.get('baseDir');
43
+ const defaultPath = './migrations';
44
+ if (!fs.pathExists(baseDir + '/src')) {
45
+ this.options.path ??= defaultPath;
46
+ return;
47
+ }
48
+ const exists = fs.pathExists(`${baseDir}/${defaultPath}`);
49
+ const distDir = fs.pathExists(baseDir + '/dist');
50
+ const buildDir = fs.pathExists(baseDir + '/build');
51
+ // if neither `dist` nor `build` exist, we use the `src` folder as it might be a JS project without building, but with `src` folder
52
+ /* v8 ignore next */
53
+ const path = distDir ? './dist' : (buildDir ? './build' : './src');
54
+ // only if the user did not provide any values and if the default path does not exist
55
+ if (!this.options.path && !this.options.pathTs && !exists) {
56
+ this.options.path = `${path}/migrations`;
57
+ this.options.pathTs = './src/migrations';
58
+ }
59
+ }
35
60
  /**
36
61
  * @inheritDoc
37
62
  */
38
- async createMigration(path, blank = false, initial = false, name) {
39
- await this.ensureMigrationsDirExists();
63
+ async create(path, blank = false, initial = false, name) {
64
+ this.ensureMigrationsDirExists();
40
65
  const diff = { up: [], down: [] };
41
66
  const migration = await this.generator.generate(diff, path, name);
42
67
  return {
@@ -45,17 +70,16 @@ class Migrator {
45
70
  diff,
46
71
  };
47
72
  }
48
- /**
49
- * @inheritDoc
50
- */
51
- async checkMigrationNeeded() {
73
+ /** @inheritDoc */
74
+ /* v8 ignore next */
75
+ async checkSchema() {
52
76
  return true;
53
77
  }
54
78
  /**
55
79
  * @inheritDoc
56
80
  */
57
- async createInitialMigration(path) {
58
- return this.createMigration(path);
81
+ async createInitial(path) {
82
+ return this.create(path);
59
83
  }
60
84
  /**
61
85
  * @inheritDoc
@@ -72,13 +96,13 @@ class Migrator {
72
96
  return this;
73
97
  }
74
98
  createUmzug() {
75
- this.runner = new MigrationRunner_1.MigrationRunner(this.driver, this.options);
76
- this.storage = new MigrationStorage_1.MigrationStorage(this.driver, this.options);
99
+ this.runner = new MigrationRunner(this.driver, this.options);
100
+ this.storage = new MigrationStorage(this.driver, this.options);
77
101
  let migrations = {
78
- glob: (0, node_path_1.join)(this.absolutePath, this.options.glob).replace(/\\/g, '/'),
102
+ glob: join(this.absolutePath, this.options.glob).replace(/\\/g, '/'),
79
103
  resolve: (params) => this.resolve(params),
80
104
  };
81
- /* istanbul ignore next */
105
+ /* v8 ignore next */
82
106
  if (this.options.migrationsList) {
83
107
  migrations = this.options.migrationsList.map(migration => {
84
108
  if (typeof migration === 'function') {
@@ -87,7 +111,7 @@ class Migrator {
87
111
  return this.initialize(migration.class, migration.name);
88
112
  });
89
113
  }
90
- this.umzug = new umzug_1.Umzug({
114
+ this.umzug = new Umzug({
91
115
  storage: this.storage,
92
116
  logger: undefined,
93
117
  migrations,
@@ -99,29 +123,29 @@ class Migrator {
99
123
  this.umzug.on('reverting', event => logger.log('migrator', `Processing '${event.name}'`, { enabled: true }));
100
124
  this.umzug.on('reverted', event => logger.log('migrator', `Reverted '${event.name}'`, { enabled: true }));
101
125
  }
102
- /* istanbul ignore next */
126
+ /* v8 ignore next */
103
127
  if (this.options.generator) {
104
128
  this.generator = new this.options.generator(this.driver, this.config.getNamingStrategy(), this.options);
105
129
  }
106
130
  else if (this.options.emit === 'js' || this.options.emit === 'cjs') {
107
- this.generator = new JSMigrationGenerator_1.JSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
131
+ this.generator = new JSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
108
132
  }
109
133
  else {
110
- this.generator = new TSMigrationGenerator_1.TSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
134
+ this.generator = new TSMigrationGenerator(this.driver, this.config.getNamingStrategy(), this.options);
111
135
  }
112
136
  }
113
137
  /**
114
138
  * @inheritDoc
115
139
  */
116
- async getExecutedMigrations() {
117
- await this.ensureMigrationsDirExists();
140
+ async getExecuted() {
141
+ this.ensureMigrationsDirExists();
118
142
  return this.storage.getExecutedMigrations();
119
143
  }
120
144
  /**
121
145
  * @inheritDoc
122
146
  */
123
- async getPendingMigrations() {
124
- await this.ensureMigrationsDirExists();
147
+ async getPending() {
148
+ this.ensureMigrationsDirExists();
125
149
  return this.umzug.pending();
126
150
  }
127
151
  /**
@@ -141,8 +165,8 @@ class Migrator {
141
165
  }
142
166
  resolve(params) {
143
167
  const createMigrationHandler = async (method) => {
144
- const migration = await core_1.Utils.dynamicImport(params.path);
145
- const MigrationClass = Object.values(migration)[0];
168
+ const migration = await Utils.dynamicImport(params.path);
169
+ const MigrationClass = Object.values(migration).find(cls => typeof cls === 'function' && typeof cls.constructor === 'function');
146
170
  const instance = new MigrationClass(this.driver, this.config);
147
171
  await this.runner.run(instance, method);
148
172
  };
@@ -152,12 +176,12 @@ class Migrator {
152
176
  down: () => createMigrationHandler('down'),
153
177
  };
154
178
  }
155
- /* istanbul ignore next */
156
179
  initialize(MigrationClass, name) {
157
180
  const instance = new MigrationClass(this.driver, this.config);
158
181
  return {
159
182
  name: this.storage.getMigrationName(name),
160
183
  up: () => this.runner.run(instance, 'up'),
184
+ /* v8 ignore next */
161
185
  down: () => this.runner.run(instance, 'down'),
162
186
  };
163
187
  }
@@ -166,8 +190,8 @@ class Migrator {
166
190
  return name.match(/^\d{14}$/) ? this.options.fileName(name) : name;
167
191
  }
168
192
  prefix(options) {
169
- if (core_1.Utils.isString(options) || Array.isArray(options)) {
170
- return { migrations: core_1.Utils.asArray(options).map(name => this.getMigrationFilename(name)) };
193
+ if (typeof options === 'string' || Array.isArray(options)) {
194
+ return { migrations: Utils.asArray(options).map(name => this.getMigrationFilename(name)) };
171
195
  }
172
196
  if (!options) {
173
197
  return {};
@@ -182,11 +206,11 @@ class Migrator {
182
206
  return options;
183
207
  }
184
208
  async runMigrations(method, options) {
185
- await this.ensureMigrationsDirExists();
209
+ this.ensureMigrationsDirExists();
186
210
  if (!this.options.transactional || !this.options.allOrNothing) {
187
211
  return this.umzug[method](this.prefix(options));
188
212
  }
189
- if (core_1.Utils.isObject(options) && options.transaction) {
213
+ if (Utils.isObject(options) && options.transaction) {
190
214
  return this.runInTransaction(options.transaction, method, options);
191
215
  }
192
216
  return this.driver.getConnection().transactional(trx => this.runInTransaction(trx, method, options));
@@ -199,10 +223,9 @@ class Migrator {
199
223
  this.storage.unsetMasterMigration();
200
224
  return ret;
201
225
  }
202
- async ensureMigrationsDirExists() {
226
+ ensureMigrationsDirExists() {
203
227
  if (!this.options.migrationsList) {
204
- await (0, fs_extra_1.ensureDir)(this.absolutePath);
228
+ fs.ensureDir(this.absolutePath);
205
229
  }
206
230
  }
207
231
  }
208
- exports.Migrator = Migrator;
package/README.md CHANGED
@@ -11,7 +11,6 @@ TypeScript ORM for Node.js based on Data Mapper, [Unit of Work](https://mikro-or
11
11
  [![Chat on discord](https://img.shields.io/discord/1214904142443839538?label=discord&color=blue)](https://discord.gg/w8bjxFHS7X)
12
12
  [![Downloads](https://img.shields.io/npm/dm/@mikro-orm/core.svg)](https://www.npmjs.com/package/@mikro-orm/core)
13
13
  [![Coverage Status](https://img.shields.io/coveralls/mikro-orm/mikro-orm.svg)](https://coveralls.io/r/mikro-orm/mikro-orm?branch=master)
14
- [![Maintainability](https://api.codeclimate.com/v1/badges/27999651d3adc47cfa40/maintainability)](https://codeclimate.com/github/mikro-orm/mikro-orm/maintainability)
15
14
  [![Build Status](https://github.com/mikro-orm/mikro-orm/workflows/tests/badge.svg?branch=master)](https://github.com/mikro-orm/mikro-orm/actions?workflow=tests)
16
15
 
17
16
  ## 🤔 Unit of What?
@@ -141,7 +140,7 @@ There is also auto-generated [CHANGELOG.md](CHANGELOG.md) file based on commit m
141
140
  - [Composite and Foreign Keys as Primary Key](https://mikro-orm.io/docs/composite-keys)
142
141
  - [Filters](https://mikro-orm.io/docs/filters)
143
142
  - [Using `QueryBuilder`](https://mikro-orm.io/docs/query-builder)
144
- - [Preloading Deeply Nested Structures via populate](https://mikro-orm.io/docs/nested-populate)
143
+ - [Populating relations](https://mikro-orm.io/docs/populating-relations)
145
144
  - [Property Validation](https://mikro-orm.io/docs/property-validation)
146
145
  - [Lifecycle Hooks](https://mikro-orm.io/docs/events#hooks)
147
146
  - [Vanilla JS Support](https://mikro-orm.io/docs/usage-with-js)
@@ -382,6 +381,8 @@ See also the list of contributors who [participated](https://github.com/mikro-or
382
381
 
383
382
  Please ⭐️ this repository if this project helped you!
384
383
 
384
+ > If you'd like to support my open-source work, consider sponsoring me directly at [github.com/sponsors/b4nan](https://github.com/sponsors/b4nan).
385
+
385
386
  ## 📝 License
386
387
 
387
388
  Copyright © 2018 [Martin Adámek](https://github.com/b4nan).
@@ -1,4 +1,4 @@
1
- import { MigrationGenerator } from './MigrationGenerator';
1
+ import { MigrationGenerator } from './MigrationGenerator.js';
2
2
  export declare class TSMigrationGenerator extends MigrationGenerator {
3
3
  /**
4
4
  * @inheritDoc
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TSMigrationGenerator = void 0;
4
- const MigrationGenerator_1 = require("./MigrationGenerator");
5
- class TSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
1
+ import { MigrationGenerator } from './MigrationGenerator.js';
2
+ export class TSMigrationGenerator extends MigrationGenerator {
6
3
  /**
7
4
  * @inheritDoc
8
5
  */
@@ -10,10 +7,10 @@ class TSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
10
7
  let ret = `import { Migration } from '@mikro-orm/migrations-mongodb';\n\n`;
11
8
  ret += `export class ${className} extends Migration {\n\n`;
12
9
  ret += ` async up(): Promise<void> {\n`;
13
- /* istanbul ignore next */
10
+ /* v8 ignore next */
14
11
  diff.up.forEach(sql => ret += this.createStatement(sql, 4));
15
12
  ret += ` }\n\n`;
16
- /* istanbul ignore next */
13
+ /* v8 ignore next */
17
14
  if (diff.down.length > 0) {
18
15
  ret += ` async down(): Promise<void> {\n`;
19
16
  diff.down.forEach(sql => ret += this.createStatement(sql, 4));
@@ -23,4 +20,3 @@ class TSMigrationGenerator extends MigrationGenerator_1.MigrationGenerator {
23
20
  return ret;
24
21
  }
25
22
  }
26
- exports.TSMigrationGenerator = TSMigrationGenerator;
package/index.d.ts CHANGED
@@ -2,11 +2,11 @@
2
2
  * @packageDocumentation
3
3
  * @module migrations-mongodb
4
4
  */
5
- export * from './Migrator';
6
- export * from './Migration';
7
- export * from './MigrationRunner';
8
- export * from './MigrationGenerator';
9
- export * from './JSMigrationGenerator';
10
- export * from './TSMigrationGenerator';
11
- export * from './MigrationStorage';
12
- export * from './typings';
5
+ export * from './Migrator.js';
6
+ export * from './Migration.js';
7
+ export * from './MigrationRunner.js';
8
+ export * from './MigrationGenerator.js';
9
+ export * from './JSMigrationGenerator.js';
10
+ export * from './TSMigrationGenerator.js';
11
+ export * from './MigrationStorage.js';
12
+ export * from './typings.js';
package/index.js CHANGED
@@ -1,28 +1,12 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
1
  /**
18
2
  * @packageDocumentation
19
3
  * @module migrations-mongodb
20
4
  */
21
- __exportStar(require("./Migrator"), exports);
22
- __exportStar(require("./Migration"), exports);
23
- __exportStar(require("./MigrationRunner"), exports);
24
- __exportStar(require("./MigrationGenerator"), exports);
25
- __exportStar(require("./JSMigrationGenerator"), exports);
26
- __exportStar(require("./TSMigrationGenerator"), exports);
27
- __exportStar(require("./MigrationStorage"), exports);
28
- __exportStar(require("./typings"), exports);
5
+ export * from './Migrator.js';
6
+ export * from './Migration.js';
7
+ export * from './MigrationRunner.js';
8
+ export * from './MigrationGenerator.js';
9
+ export * from './JSMigrationGenerator.js';
10
+ export * from './TSMigrationGenerator.js';
11
+ export * from './MigrationStorage.js';
12
+ export * from './typings.js';
package/package.json CHANGED
@@ -1,19 +1,11 @@
1
1
  {
2
2
  "name": "@mikro-orm/migrations-mongodb",
3
- "version": "7.0.0-dev.1",
3
+ "type": "module",
4
+ "version": "7.0.0-dev.100",
4
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.",
5
- "main": "index.js",
6
- "module": "index.mjs",
7
- "typings": "index.d.ts",
8
6
  "exports": {
9
7
  "./package.json": "./package.json",
10
- ".": {
11
- "import": {
12
- "types": "./index.d.ts",
13
- "default": "./index.mjs"
14
- },
15
- "require": "./index.js"
16
- }
8
+ ".": "./index.js"
17
9
  },
18
10
  "repository": {
19
11
  "type": "git",
@@ -46,10 +38,10 @@
46
38
  },
47
39
  "homepage": "https://mikro-orm.io",
48
40
  "engines": {
49
- "node": ">= 22.11.0"
41
+ "node": ">= 22.17.0"
50
42
  },
51
43
  "scripts": {
52
- "build": "yarn clean && yarn compile && yarn copy && yarn run -T gen-esm-wrapper index.js index.mjs",
44
+ "build": "yarn clean && yarn compile && yarn copy",
53
45
  "clean": "yarn run -T rimraf ./dist",
54
46
  "compile": "yarn run -T tsc -p tsconfig.build.json",
55
47
  "copy": "node ../../scripts/copy.mjs"
@@ -58,15 +50,14 @@
58
50
  "access": "public"
59
51
  },
60
52
  "dependencies": {
61
- "@mikro-orm/mongodb": "7.0.0-dev.1",
62
- "fs-extra": "11.3.0",
63
- "mongodb": "6.13.0",
53
+ "@mikro-orm/mongodb": "7.0.0-dev.100",
54
+ "mongodb": "7.0.0",
64
55
  "umzug": "3.8.2"
65
56
  },
66
57
  "devDependencies": {
67
- "@mikro-orm/core": "^6.4.5"
58
+ "@mikro-orm/core": "^6.6.2"
68
59
  },
69
60
  "peerDependencies": {
70
- "@mikro-orm/core": "7.0.0-dev.1"
61
+ "@mikro-orm/core": "7.0.0-dev.100"
71
62
  }
72
63
  }
package/typings.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/index.mjs DELETED
@@ -1,10 +0,0 @@
1
- import mod from "./index.js";
2
-
3
- export default mod;
4
- export const JSMigrationGenerator = mod.JSMigrationGenerator;
5
- export const Migration = mod.Migration;
6
- export const MigrationGenerator = mod.MigrationGenerator;
7
- export const MigrationRunner = mod.MigrationRunner;
8
- export const MigrationStorage = mod.MigrationStorage;
9
- export const Migrator = mod.Migrator;
10
- export const TSMigrationGenerator = mod.TSMigrationGenerator;