@mikro-orm/mongodb 7.0.0-dev.8 → 7.0.0-dev.9

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.
@@ -4,10 +4,10 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
4
4
  orm.config.registerExtension('@mikro-orm/schema-generator', () => new MongoSchemaGenerator(orm.em));
5
5
  }
6
6
  async createSchema(options = {}) {
7
+ await this.connection.ensureConnection();
7
8
  options.ensureIndexes ??= true;
8
9
  const existing = await this.connection.listCollections();
9
10
  const metadata = this.getOrderedMetadata();
10
- metadata.push({ collection: this.config.get('migrations').tableName });
11
11
  /* v8 ignore start */
12
12
  const promises = metadata
13
13
  .filter(meta => !existing.includes(meta.collection))
@@ -25,9 +25,8 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
25
25
  await Promise.all(promises);
26
26
  }
27
27
  async dropSchema(options = {}) {
28
- const db = this.connection.getDb();
29
- const collections = await db.listCollections().toArray();
30
- const existing = collections.map(c => c.name);
28
+ await this.connection.ensureConnection();
29
+ const existing = await this.connection.listCollections();
31
30
  const metadata = this.getOrderedMetadata();
32
31
  if (options.dropMigrationsTable) {
33
32
  metadata.push({ collection: this.config.get('migrations').tableName });
@@ -49,6 +48,7 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
49
48
  await this.createSchema(options);
50
49
  }
51
50
  async dropIndexes(options) {
51
+ await this.connection.ensureConnection();
52
52
  const db = this.connection.getDb();
53
53
  const collections = await db.listCollections().toArray();
54
54
  const promises = [];
@@ -68,6 +68,7 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
68
68
  await Promise.all(promises);
69
69
  }
70
70
  async ensureIndexes(options = {}) {
71
+ await this.connection.ensureConnection();
71
72
  options.ensureCollections ??= true;
72
73
  options.retryLimit ??= 3;
73
74
  if (options.ensureCollections) {
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.8",
4
+ "version": "7.0.0-dev.9",
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",
@@ -50,12 +50,12 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "mongodb": "6.14.2"
53
+ "mongodb": "6.15.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@mikro-orm/core": "^6.4.9"
56
+ "@mikro-orm/core": "^6.4.13"
57
57
  },
58
58
  "peerDependencies": {
59
- "@mikro-orm/core": "7.0.0-dev.8"
59
+ "@mikro-orm/core": "7.0.0-dev.9"
60
60
  }
61
61
  }