@mikro-orm/core 6.3.13-dev.9 → 6.3.13

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.
@@ -115,7 +115,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
115
115
  setFlushMode(flushMode?: FlushMode): void;
116
116
  protected processWhere<Entity extends object, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entityName: string, where: FilterQuery<Entity>, options: FindOptions<Entity, Hint, Fields, Excludes> | FindOneOptions<Entity, Hint, Fields, Excludes>, type: 'read' | 'update' | 'delete'): Promise<FilterQuery<Entity>>;
117
117
  protected applyDiscriminatorCondition<Entity extends object>(entityName: string, where: FilterQuery<Entity>): FilterQuery<Entity>;
118
- protected createPopulateWhere<Entity extends object>(cond: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any>): ObjectQuery<Entity>;
118
+ protected createPopulateWhere<Entity extends object>(cond: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any> | CountOptions<Entity, any>): ObjectQuery<Entity>;
119
119
  protected getJoinedFilters<Entity extends object>(meta: EntityMetadata<Entity>, cond: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any>): Promise<ObjectQuery<Entity>>;
120
120
  /**
121
121
  * When filters are active on M:1 or 1:1 relations, we need to ref join them eagerly as they might affect the FK value.
package/EntityManager.js CHANGED
@@ -1230,6 +1230,12 @@ class EntityManager {
1230
1230
  await em.tryFlush(entityName, options);
1231
1231
  where = await em.processWhere(entityName, where, options, 'read');
1232
1232
  options.populate = await em.preparePopulate(entityName, options);
1233
+ options = { ...options };
1234
+ // save the original hint value so we know it was infer/all
1235
+ const meta = em.metadata.find(entityName);
1236
+ options._populateWhere = options.populateWhere ?? this.config.get('populateWhere');
1237
+ options.populateWhere = this.createPopulateWhere({ ...where }, options);
1238
+ options.populateFilter = await this.getJoinedFilters(meta, { ...where }, options);
1233
1239
  em.validator.validateParams(where);
1234
1240
  delete options.orderBy;
1235
1241
  const cacheKey = em.cacheKey(entityName, options, 'em.count', where);
@@ -2,6 +2,7 @@ import { type Cascade, type LoadStrategy } from '../enums';
2
2
  import type { EntityName, Constructor, CheckCallback, GeneratedColumnCallback, AnyString, AnyEntity } from '../typings';
3
3
  import type { Type, types } from '../types';
4
4
  import type { EntityManager } from '../EntityManager';
5
+ import type { SerializeOptions } from '../serialization/EntitySerializer';
5
6
  export declare function Property<T extends object>(options?: PropertyOptions<T>): (target: any, propertyName: string) => any;
6
7
  export interface PropertyOptions<Owner> {
7
8
  /**
@@ -188,7 +189,7 @@ export interface PropertyOptions<Owner> {
188
189
  *
189
190
  * @see https://mikro-orm.io/docs/serializing#property-serializers
190
191
  */
191
- serializer?: (value: any) => any;
192
+ serializer?: (value: any, options?: SerializeOptions<any>) => any;
192
193
  /**
193
194
  * Specify name of key for the serialized value.
194
195
  */
@@ -86,7 +86,7 @@ export interface FindOptions<Entity, Hint extends string = never, Fields extends
86
86
  * Filter condition for populated relations. This is similar to `populateWhere`, but will produce a `left join`
87
87
  * when nesting the condition. This is used for implementation of joined filters.
88
88
  */
89
- populateFilter?: ObjectQuery<Entity> | PopulateHint | `${PopulateHint}`;
89
+ populateFilter?: ObjectQuery<Entity>;
90
90
  /** Used for ordering of the populate queries. If not specified, the value of `options.orderBy` is used. */
91
91
  populateOrderBy?: OrderDefinition<Entity>;
92
92
  /** Ordering of the results.Can be an object or array of objects, keys are property names, values are ordering (asc/desc) */
@@ -182,6 +182,8 @@ export interface CountOptions<T extends object, P extends string = never> {
182
182
  having?: QBFilterQuery<T>;
183
183
  cache?: boolean | number | [string, number];
184
184
  populate?: Populate<T, P>;
185
+ populateWhere?: ObjectQuery<T> | PopulateHint | `${PopulateHint}`;
186
+ populateFilter?: ObjectQuery<T>;
185
187
  ctx?: Transaction;
186
188
  connectionType?: ConnectionType;
187
189
  flushMode?: FlushMode | `${FlushMode}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.3.13-dev.9",
3
+ "version": "6.3.13",
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
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.2.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.3.13-dev.9",
67
+ "mikro-orm": "6.3.13",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -118,7 +118,7 @@ class EntitySerializer {
118
118
  if (entity[prop] instanceof Function) {
119
119
  const returnValue = entity[prop]();
120
120
  if (!options.ignoreSerializers && serializer) {
121
- return serializer(returnValue);
121
+ return serializer(returnValue, this.extractChildOptions(options, prop));
122
122
  }
123
123
  return returnValue;
124
124
  }
package/typings.d.ts CHANGED
@@ -366,7 +366,7 @@ export interface EntityProperty<Owner = any, Target = any> {
366
366
  referencedColumnNames: string[];
367
367
  referencedTableName: string;
368
368
  referencedPKs: EntityKey<Owner>[];
369
- serializer?: (value: any) => any;
369
+ serializer?: (value: any, options?: SerializeOptions<any>) => any;
370
370
  serializedName?: string;
371
371
  comment?: string;
372
372
  /** mysql only */