@mikro-orm/mongodb 7.0.0-dev.75 → 7.0.0-dev.77

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.
@@ -28,7 +28,7 @@ export class MongoConnection extends Connection {
28
28
  this.client = new MongoClient(this.config.get('clientUrl'), this.mapOptions(driverOptions));
29
29
  await this.client.connect();
30
30
  const onCreateConnection = this.options.onCreateConnection ?? this.config.get('onCreateConnection');
31
- /* v8 ignore next 3 */
31
+ /* v8 ignore next */
32
32
  this.client.on('connectionCreated', () => {
33
33
  void onCreateConnection?.(this.client);
34
34
  });
package/MongoDriver.js CHANGED
@@ -86,7 +86,7 @@ export class MongoDriver extends DatabaseDriver {
86
86
  const em = this.createEntityManager();
87
87
  return meta.expression(em, where, options);
88
88
  }
89
- /* v8 ignore next 2 */
89
+ /* v8 ignore next */
90
90
  return super.findVirtual(entityName, where, options);
91
91
  }
92
92
  async *streamVirtual(entityName, where, options) {
@@ -97,11 +97,11 @@ export class MongoDriver extends DatabaseDriver {
97
97
  yield* stream;
98
98
  return;
99
99
  }
100
- /* v8 ignore next 2 */
100
+ /* v8 ignore next */
101
101
  return super.findVirtual(entityName, where, options);
102
102
  }
103
103
  async count(entityName, where, options = {}, ctx) {
104
- /* v8 ignore next 3 */
104
+ /* v8 ignore next */
105
105
  if (this.metadata.find(entityName)?.virtual) {
106
106
  return this.countVirtual(entityName, where, options);
107
107
  }
@@ -217,7 +217,7 @@ export class MongoDriver extends DatabaseDriver {
217
217
  for (let i = 0; i < copiedData.$and.length; i++) {
218
218
  const and = copiedData.$and[i];
219
219
  if ('$fulltext' in and) {
220
- /* v8 ignore next 3 */
220
+ /* v8 ignore next */
221
221
  if ('$fulltext' in copiedData) {
222
222
  throw new Error('Cannot merge multiple $fulltext conditions to top level of the query object.');
223
223
  }
@@ -238,7 +238,7 @@ export class MongoDriver extends DatabaseDriver {
238
238
  }
239
239
  Utils.keys(copiedData).forEach(k => {
240
240
  if (k in GroupOperator) {
241
- /* v8 ignore next 5 */
241
+ /* v8 ignore next */
242
242
  if (Array.isArray(copiedData[k])) {
243
243
  copiedData[k] = copiedData[k].map(v => this.renameFields(entityName, v));
244
244
  }
@@ -315,7 +315,7 @@ export class MongoDriver extends DatabaseDriver {
315
315
  const ret = [];
316
316
  if (fields) {
317
317
  for (let field of fields) {
318
- /* v8 ignore next 3 */
318
+ /* v8 ignore next */
319
319
  if (Utils.isPlainObject(field)) {
320
320
  continue;
321
321
  }
@@ -323,7 +323,7 @@ export class MongoDriver extends DatabaseDriver {
323
323
  field = field.toString().substring(0, field.toString().indexOf('.'));
324
324
  }
325
325
  let prop = meta.properties[field];
326
- /* v8 ignore start */
326
+ /* v8 ignore next */
327
327
  if (prop) {
328
328
  if (!prop.fieldNames) {
329
329
  continue;
@@ -338,7 +338,6 @@ export class MongoDriver extends DatabaseDriver {
338
338
  else {
339
339
  ret.push(field);
340
340
  }
341
- /* v8 ignore stop */
342
341
  }
343
342
  ret.unshift(...meta.primaryKeys.filter(pk => !fields.includes(pk)));
344
343
  }
@@ -1,5 +1,5 @@
1
1
  import { UniqueConstraintViolationException, ExceptionConverter, TableExistsException } from '@mikro-orm/core';
2
- /* v8 ignore start */
2
+ /* v8 ignore next */
3
3
  export class MongoExceptionConverter extends ExceptionConverter {
4
4
  /**
5
5
  * @see https://gist.github.com/rluvaton/a97a8da46ab6541a3e5702e83b9d357b
@@ -14,4 +14,3 @@ export class MongoExceptionConverter extends ExceptionConverter {
14
14
  return super.convertException(exception);
15
15
  }
16
16
  }
17
- /* v8 ignore stop */
@@ -1,4 +1,4 @@
1
- import { type AnyEntity, type EntityClass, type EntitySchema, MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType } from '@mikro-orm/core';
1
+ import { type AnyEntity, type EntityClass, type EntitySchema, MikroORM, type Options, type IDatabaseDriver, type EntityManager, type EntityManagerType, type IMigrator } from '@mikro-orm/core';
2
2
  import { MongoDriver } from './MongoDriver.js';
3
3
  import type { MongoEntityManager } from './MongoEntityManager.js';
4
4
  export type MongoOptions<EM extends MongoEntityManager = MongoEntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = Options<MongoDriver, EM, Entities>;
@@ -15,4 +15,8 @@ export declare class MongoMikroORM<EM extends MongoEntityManager = MongoEntityMa
15
15
  * @inheritDoc
16
16
  */
17
17
  constructor(options: Options<MongoDriver, EM, Entities>);
18
+ /**
19
+ * Gets the Migrator.
20
+ */
21
+ get migrator(): IMigrator;
18
22
  }
package/MongoMikroORM.js CHANGED
@@ -19,4 +19,10 @@ export class MongoMikroORM extends MikroORM {
19
19
  constructor(options) {
20
20
  super(defineMongoConfig(options));
21
21
  }
22
+ /**
23
+ * Gets the Migrator.
24
+ */
25
+ get migrator() {
26
+ return this.driver.getPlatform().getExtension('Migrator', '@mikro-orm/migrator', '@mikro-orm/migrations-mongodb', this.em);
27
+ }
22
28
  }
package/MongoPlatform.js CHANGED
@@ -32,7 +32,7 @@ export class MongoPlatform extends Platform {
32
32
  /* v8 ignore next */
33
33
  return super.getExtension(extensionName, extensionKey, moduleName, em);
34
34
  }
35
- /* v8 ignore next 3: kept for type inference only */
35
+ /* v8 ignore next: kept for type inference only */
36
36
  getSchemaGenerator(driver, em) {
37
37
  return new MongoSchemaGenerator(em ?? driver);
38
38
  }
@@ -9,7 +9,7 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
9
9
  options.ensureIndexes ??= true;
10
10
  const existing = await this.connection.listCollections();
11
11
  const metadata = this.getOrderedMetadata();
12
- /* v8 ignore start */
12
+ /* v8 ignore next */
13
13
  const promises = metadata
14
14
  .filter(meta => !existing.includes(meta.collection))
15
15
  .map(meta => this.connection.createCollection(meta.collection).catch(err => {
@@ -19,7 +19,6 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
19
19
  throw err;
20
20
  }
21
21
  }));
22
- /* v8 ignore stop */
23
22
  if (options.ensureIndexes) {
24
23
  await this.ensureIndexes({ ensureCollections: false });
25
24
  }
@@ -60,7 +59,7 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
60
59
  const indexes = await db.collection(collection.name).listIndexes().toArray();
61
60
  for (const index of indexes) {
62
61
  const isIdIndex = index.key._id === 1 && Utils.getObjectKeysSize(index.key) === 1;
63
- /* v8 ignore next 3 */
62
+ /* v8 ignore next */
64
63
  if (!isIdIndex && !options?.skipIndexes?.find(idx => idx.collection === collection.name && idx.indexName === index.name)) {
65
64
  promises.push(this.executeQuery(db.collection(collection.name), 'dropIndex', index.name));
66
65
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/mongodb",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.75",
4
+ "version": "7.0.0-dev.77",
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",
@@ -56,6 +56,6 @@
56
56
  "@mikro-orm/core": "^6.6.1"
57
57
  },
58
58
  "peerDependencies": {
59
- "@mikro-orm/core": "7.0.0-dev.75"
59
+ "@mikro-orm/core": "7.0.0-dev.77"
60
60
  }
61
61
  }