@mikro-orm/mongodb 7.2.9-dev.9 → 7.2.10-dev.0

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.
@@ -17,7 +17,7 @@ export declare class MongoEntityManager<Driver extends MongoDriver = MongoDriver
17
17
  /**
18
18
  * @inheritDoc
19
19
  */
20
- stream<Entity extends object, Hint extends string = never, Fields extends string = never, Excludes extends string = never, Using extends string = never>(entityName: EntityName<Entity>, options?: WithUsingOptions<StreamOptions<NoInfer<Entity>, Hint, Fields, Excludes>, NoInfer<Entity>, Using>): AsyncIterableIterator<Loaded<Entity, Hint, Fields, Excludes>>;
20
+ stream<Entity extends object, Hint extends string = never, Fields extends string = never, Excludes extends string = never, Using extends string = never>(entityName: EntityName<Entity>, options?: WithUsingOptions<StreamOptions<Entity, Hint, Fields, Excludes>, NoInfer<Entity>, Using>): AsyncIterableIterator<Loaded<Entity, Hint, Fields, Excludes>>;
21
21
  getCollection<T extends Document>(entityOrCollectionName: EntityName<T> | string): Collection<T>;
22
22
  /**
23
23
  * @inheritDoc
@@ -138,7 +138,7 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
138
138
  // The array-form escape hatch passes raw [spec, options] to the driver; fold `where`
139
139
  // into the options dict (on a clone, to avoid mutating the user's metadata).
140
140
  const opts = { ...index.options[1] };
141
- this.applyPartialFilter(opts, index.where, index.name, meta.className);
141
+ this.applyPartialFilter(opts, index.where, index.name, meta);
142
142
  res.push([collection.collectionName, collection.createIndex(index.options[0], opts)]);
143
143
  return;
144
144
  }
@@ -176,7 +176,7 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
176
176
  if (index.invisible) {
177
177
  indexOptions.hidden = true;
178
178
  }
179
- this.applyPartialFilter(indexOptions, index.where, index.name, meta.className);
179
+ this.applyPartialFilter(indexOptions, index.where, index.name, meta);
180
180
  res.push([collection.collectionName, this.executeQuery(collection, 'createIndex', fieldOrSpec, indexOptions)]);
181
181
  });
182
182
  return res;
@@ -185,20 +185,21 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
185
185
  * An explicit `options.partialFilterExpression` wins over `where` — this preserves the
186
186
  * long-standing `options: { partialFilterExpression }` escape hatch.
187
187
  */
188
- applyPartialFilter(options, where, indexName, entityName) {
188
+ applyPartialFilter(options, where, indexName, meta) {
189
189
  if (where == null) {
190
190
  return;
191
191
  }
192
192
  if (options.partialFilterExpression != null) {
193
193
  this.config
194
194
  .getLogger()
195
- .warn('schema', `Index '${indexName ?? '(unnamed)'}' on entity '${entityName}': both \`where\` and \`options.partialFilterExpression\` are set; \`options.partialFilterExpression\` wins.`);
195
+ .warn('schema', `Index '${indexName ?? '(unnamed)'}' on entity '${meta.className}': both \`where\` and \`options.partialFilterExpression\` are set; \`options.partialFilterExpression\` wins.`);
196
196
  return;
197
197
  }
198
198
  if (typeof where === 'string') {
199
- throw new Error(`Index '${indexName ?? '(unnamed)'}' on entity '${entityName}': string \`where\` is not supported on MongoDB; pass an object/FilterQuery (it maps to MongoDB's \`partialFilterExpression\`).`);
199
+ throw new Error(`Index '${indexName ?? '(unnamed)'}' on entity '${meta.className}': string \`where\` is not supported on MongoDB; pass an object/FilterQuery (it maps to MongoDB's \`partialFilterExpression\`).`);
200
200
  }
201
- options.partialFilterExpression = where;
201
+ // map property names to field names, the same way the driver does for queries
202
+ options.partialFilterExpression = this.driver.renameFields(meta.class, where, true);
202
203
  }
203
204
  async executeQuery(collection, method, ...args) {
204
205
  const now = Date.now();
@@ -227,7 +228,7 @@ export class MongoSchemaGenerator extends AbstractSchemaGenerator {
227
228
  unique: true,
228
229
  ...index.options,
229
230
  };
230
- this.applyPartialFilter(indexOptions, index.where, index.name, meta.className);
231
+ this.applyPartialFilter(indexOptions, index.where, index.name, meta);
231
232
  res.push([collection.collectionName, this.executeQuery(collection, 'createIndex', fieldOrSpec, indexOptions)]);
232
233
  });
233
234
  return res;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/mongodb",
3
- "version": "7.2.9-dev.9",
3
+ "version": "7.2.10-dev.0",
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",
@@ -50,10 +50,10 @@
50
50
  "mongodb": "7.8.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@mikro-orm/core": "^7.2.8"
53
+ "@mikro-orm/core": "^7.2.9"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.2.9-dev.9"
56
+ "@mikro-orm/core": "7.2.10-dev.0"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"