@mikro-orm/core 7.0.0-dev.136 → 7.0.0-dev.138

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.
@@ -7,7 +7,7 @@ import { EntityLoader, type EntityLoaderOptions } from './entity/EntityLoader.js
7
7
  import { Reference } from './entity/Reference.js';
8
8
  import { UnitOfWork } from './unit-of-work/UnitOfWork.js';
9
9
  import type { CountOptions, DeleteOptions, FilterOptions, FindAllOptions, FindByCursorOptions, FindOneOptions, FindOneOrFailOptions, FindOptions, GetReferenceOptions, IDatabaseDriver, LockOptions, NativeInsertUpdateOptions, StreamOptions, UpdateOptions, UpsertManyOptions, UpsertOptions } from './drivers/IDatabaseDriver.js';
10
- import type { AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityClass, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, Primary, Ref, RequiredEntityData, UnboxArray } from './typings.js';
10
+ import type { AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityClass, EntityData, EntityDictionary, EntityDTO, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MergeLoaded, MergeSelected, NoInfer, ObjectQuery, PopulateOptions, Primary, Ref, RequiredEntityData, UnboxArray } from './typings.js';
11
11
  import { FlushMode, LockMode, PopulatePath, type TransactionOptions } from './enums.js';
12
12
  import type { MetadataStorage } from './metadata/MetadataStorage.js';
13
13
  import type { Transaction } from './connections/Connection.js';
@@ -498,7 +498,8 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
498
498
  private checkLockRequirements;
499
499
  private lockAndPopulate;
500
500
  private buildFields;
501
- private preparePopulate;
501
+ /** @internal */
502
+ preparePopulate<Entity extends object>(entityName: EntityName<Entity>, options: Pick<FindOptions<Entity, any, any>, 'populate' | 'strategy' | 'fields' | 'flags' | 'filters'>, validate?: boolean): Promise<PopulateOptions<Entity>[]>;
502
503
  /**
503
504
  * when the entity is found in identity map, we check if it was partially loaded or we are trying to populate
504
505
  * some additional lazy properties, if so, we reload and merge the data from database
package/EntityManager.js CHANGED
@@ -1601,6 +1601,7 @@ export class EntityManager {
1601
1601
  return ret;
1602
1602
  }, []);
1603
1603
  }
1604
+ /** @internal */
1604
1605
  async preparePopulate(entityName, options, validate = true) {
1605
1606
  if (options.populate === false) {
1606
1607
  return [];
@@ -96,9 +96,11 @@ export class Collection {
96
96
  opts.orderBy = this.createOrderBy(opts.orderBy);
97
97
  let items;
98
98
  if (this.property.kind === ReferenceKind.MANY_TO_MANY && em.getPlatform().usesPivotTable()) {
99
+ options.populate = await em.preparePopulate(this.property.targetMeta.class, options);
99
100
  const cond = await em.applyFilters(this.property.targetMeta.class, where, options.filters ?? {}, 'read');
100
101
  const map = await em.getDriver().loadFromPivotTable(this.property, [helper(this.owner).__primaryKeys], cond, opts.orderBy, ctx, options);
101
102
  items = map[helper(this.owner).getSerializedPrimaryKey()].map((item) => em.merge(this.property.targetMeta.class, item, { convertCustomTypes: true }));
103
+ await em.populate(items, options.populate, options);
102
104
  }
103
105
  else {
104
106
  items = await em.find(this.property.targetMeta.class, this.createCondition(where), opts);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.136",
4
+ "version": "7.0.0-dev.138",
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",
package/utils/Utils.js CHANGED
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
123
123
  }
124
124
  export class Utils {
125
125
  static PK_SEPARATOR = '~~~';
126
- static #ORM_VERSION = '7.0.0-dev.136';
126
+ static #ORM_VERSION = '7.0.0-dev.138';
127
127
  /**
128
128
  * Checks if the argument is instance of `Object`. Returns false for arrays.
129
129
  */