@mikro-orm/core 7.0.0-rc.0 → 7.0.0-rc.1
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.
- package/EntityManager.d.ts +1 -1
- package/EntityManager.js +7 -4
- package/drivers/IDatabaseDriver.d.ts +29 -5
- package/entity/defineEntity.d.ts +2 -2
- package/entity/utils.d.ts +6 -1
- package/entity/utils.js +33 -0
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/typings.d.ts +6 -2
- package/unit-of-work/ChangeSetComputer.d.ts +3 -6
- package/unit-of-work/ChangeSetComputer.js +7 -7
- package/unit-of-work/ChangeSetPersister.d.ts +7 -10
- package/unit-of-work/ChangeSetPersister.js +10 -10
- package/unit-of-work/UnitOfWork.js +2 -2
- package/utils/Utils.js +1 -1
- package/utils/fs-utils.js +2 -2
package/EntityManager.d.ts
CHANGED
|
@@ -515,7 +515,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
515
515
|
private lockAndPopulate;
|
|
516
516
|
private buildFields;
|
|
517
517
|
/** @internal */
|
|
518
|
-
preparePopulate<Entity extends object>(entityName: EntityName<Entity>, options: Pick<FindOptions<Entity, any, any, any>, 'populate' | 'strategy' | 'fields' | 'flags' | 'filters' | 'exclude'>, validate?: boolean): Promise<PopulateOptions<Entity>[]>;
|
|
518
|
+
preparePopulate<Entity extends object>(entityName: EntityName<Entity>, options: Pick<FindOptions<Entity, any, any, any>, 'populate' | 'strategy' | 'fields' | 'flags' | 'filters' | 'exclude' | 'populateHints'>, validate?: boolean): Promise<PopulateOptions<Entity>[]>;
|
|
519
519
|
/**
|
|
520
520
|
* when the entity is found in identity map, we check if it was partially loaded or we are trying to populate
|
|
521
521
|
* some additional lazy properties, if so, we reload and merge the data from database
|
package/EntityManager.js
CHANGED
|
@@ -17,7 +17,7 @@ import { EventType, FlushMode, LoadStrategy, LockMode, PopulateHint, PopulatePat
|
|
|
17
17
|
import { EventManager } from './events/EventManager.js';
|
|
18
18
|
import { TransactionEventBroadcaster } from './events/TransactionEventBroadcaster.js';
|
|
19
19
|
import { OptimisticLockError, ValidationError } from './errors.js';
|
|
20
|
-
import { getLoadingStrategy } from './entity/utils.js';
|
|
20
|
+
import { applyPopulateHints, getLoadingStrategy } from './entity/utils.js';
|
|
21
21
|
import { TransactionManager } from './utils/TransactionManager.js';
|
|
22
22
|
/**
|
|
23
23
|
* The EntityManager is the central access point to ORM functionality. It is a facade to all different ORM subsystems
|
|
@@ -1683,12 +1683,15 @@ export class EntityManager {
|
|
|
1683
1683
|
throw ValidationError.invalidPropertyName(entityName, invalid.field);
|
|
1684
1684
|
}
|
|
1685
1685
|
await this.autoJoinRefsForFilters(meta, { ...options, populate });
|
|
1686
|
-
|
|
1686
|
+
for (const field of populate) {
|
|
1687
1687
|
// force select-in strategy when populating all relations as otherwise we could cause infinite loops when self-referencing
|
|
1688
1688
|
const all = field.all ?? (Array.isArray(options.populate) && options.populate.includes('*'));
|
|
1689
1689
|
field.strategy = all ? LoadStrategy.SELECT_IN : (options.strategy ?? field.strategy);
|
|
1690
|
-
|
|
1691
|
-
|
|
1690
|
+
}
|
|
1691
|
+
if (options.populateHints) {
|
|
1692
|
+
applyPopulateHints(populate, options.populateHints);
|
|
1693
|
+
}
|
|
1694
|
+
return populate;
|
|
1692
1695
|
}
|
|
1693
1696
|
/**
|
|
1694
1697
|
* when the entity is found in identity map, we check if it was partially loaded or we are trying to populate
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectionType, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName } from '../typings.js';
|
|
1
|
+
import type { ConnectionType, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName, PopulateHintOptions, Prefixes } from '../typings.js';
|
|
2
2
|
import type { Connection, QueryResult, Transaction } from '../connections/Connection.js';
|
|
3
3
|
import type { FlushMode, LockMode, QueryOrderMap, QueryFlag, LoadStrategy, PopulateHint, PopulatePath } from '../enums.js';
|
|
4
4
|
import type { Platform } from '../platforms/Platform.js';
|
|
@@ -107,6 +107,10 @@ export interface FindOptions<Entity, Hint extends string = never, Fields extends
|
|
|
107
107
|
populateFilter?: ObjectQuery<Entity>;
|
|
108
108
|
/** Used for ordering of the populate queries. If not specified, the value of `options.orderBy` is used. */
|
|
109
109
|
populateOrderBy?: OrderDefinition<Entity>;
|
|
110
|
+
/** Per-relation overrides for populate loading behavior. Keys are populate paths (same as used in `populate`). */
|
|
111
|
+
populateHints?: [Hint] extends [never] ? never : {
|
|
112
|
+
[K in Prefixes<Hint>]?: PopulateHintOptions;
|
|
113
|
+
};
|
|
110
114
|
/** Ordering of the results.Can be an object or array of objects, keys are property names, values are ordering (asc/desc) */
|
|
111
115
|
orderBy?: OrderDefinition<Entity>;
|
|
112
116
|
/** Control result caching for this query. Result cache is by default disabled, not to be confused with the identity map. */
|
|
@@ -155,12 +159,18 @@ export interface FindOptions<Entity, Hint extends string = never, Fields extends
|
|
|
155
159
|
lockTableAliases?: string[];
|
|
156
160
|
ctx?: Transaction;
|
|
157
161
|
connectionType?: ConnectionType;
|
|
158
|
-
/**
|
|
159
|
-
indexHint?: string;
|
|
162
|
+
/** SQL: appended to FROM clause (e.g. `'force index(my_index)'`); MongoDB: index name or spec passed as `hint`. */
|
|
163
|
+
indexHint?: string | Dictionary;
|
|
160
164
|
/** sql only */
|
|
161
165
|
comments?: string | string[];
|
|
162
166
|
/** sql only */
|
|
163
167
|
hintComments?: string | string[];
|
|
168
|
+
/** SQL: collation name string applied as COLLATE to ORDER BY; MongoDB: CollationOptions object. */
|
|
169
|
+
collation?: CollationOptions | string;
|
|
170
|
+
/** mongodb only */
|
|
171
|
+
maxTimeMS?: number;
|
|
172
|
+
/** mongodb only */
|
|
173
|
+
allowDiskUse?: boolean;
|
|
164
174
|
loggerContext?: LogContext;
|
|
165
175
|
logging?: LoggingOptions;
|
|
166
176
|
/** @internal used to apply filters to the auto-joined relations */
|
|
@@ -211,12 +221,16 @@ export interface CountOptions<T extends object, P extends string = never> {
|
|
|
211
221
|
ctx?: Transaction;
|
|
212
222
|
connectionType?: ConnectionType;
|
|
213
223
|
flushMode?: FlushMode | `${FlushMode}`;
|
|
214
|
-
/**
|
|
215
|
-
indexHint?: string;
|
|
224
|
+
/** SQL: appended to FROM clause (e.g. `'force index(my_index)'`); MongoDB: index name or spec passed as `hint`. */
|
|
225
|
+
indexHint?: string | Dictionary;
|
|
216
226
|
/** sql only */
|
|
217
227
|
comments?: string | string[];
|
|
218
228
|
/** sql only */
|
|
219
229
|
hintComments?: string | string[];
|
|
230
|
+
/** SQL: collation name string applied as COLLATE; MongoDB: CollationOptions object. */
|
|
231
|
+
collation?: CollationOptions | string;
|
|
232
|
+
/** mongodb only */
|
|
233
|
+
maxTimeMS?: number;
|
|
220
234
|
loggerContext?: LogContext;
|
|
221
235
|
logging?: LoggingOptions;
|
|
222
236
|
/** @internal used to apply filters to the auto-joined relations */
|
|
@@ -244,6 +258,16 @@ export interface DriverMethodOptions {
|
|
|
244
258
|
schema?: string;
|
|
245
259
|
loggerContext?: LogContext;
|
|
246
260
|
}
|
|
261
|
+
export interface CollationOptions {
|
|
262
|
+
locale: string;
|
|
263
|
+
caseLevel?: boolean;
|
|
264
|
+
caseFirst?: string;
|
|
265
|
+
strength?: number;
|
|
266
|
+
numericOrdering?: boolean;
|
|
267
|
+
alternate?: string;
|
|
268
|
+
maxVariable?: string;
|
|
269
|
+
backwards?: boolean;
|
|
270
|
+
}
|
|
247
271
|
export interface GetReferenceOptions {
|
|
248
272
|
wrapped?: boolean;
|
|
249
273
|
convertCustomTypes?: boolean;
|
package/entity/defineEntity.d.ts
CHANGED
|
@@ -345,7 +345,7 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
345
345
|
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
346
346
|
referencedColumnNames(...referencedColumnNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
347
347
|
/** Specify the property name on the target entity that this FK references instead of the primary key. */
|
|
348
|
-
targetKey(targetKey:
|
|
348
|
+
targetKey(targetKey: keyof Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
349
349
|
/** What to do when the target entity gets deleted. */
|
|
350
350
|
deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
351
351
|
/** What to do when the reference to the target entity gets updated. */
|
|
@@ -373,7 +373,7 @@ export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> e
|
|
|
373
373
|
kind: '1:m';
|
|
374
374
|
}, IncludeKeysForOneToManyOptions> {
|
|
375
375
|
/** Point to the owning side property name. */
|
|
376
|
-
mappedBy(mappedBy: (
|
|
376
|
+
mappedBy(mappedBy: (keyof Value) | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
|
|
377
377
|
kind: '1:m';
|
|
378
378
|
}, IncludeKeysForOneToManyOptions>, IncludeKeysForOneToManyOptions>;
|
|
379
379
|
}
|
package/entity/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EntityMetadata, PopulateOptions } from '../typings.js';
|
|
1
|
+
import type { EntityMetadata, PopulateHintOptions, PopulateOptions } from '../typings.js';
|
|
2
2
|
import { LoadStrategy, ReferenceKind } from '../enums.js';
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
@@ -10,3 +10,8 @@ export declare function expandDotPaths<Entity>(meta: EntityMetadata<Entity>, pop
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export declare function getLoadingStrategy(strategy: LoadStrategy | `${LoadStrategy}`, kind: ReferenceKind): LoadStrategy.SELECT_IN | LoadStrategy.JOINED;
|
|
13
|
+
/**
|
|
14
|
+
* Applies per-relation overrides from `populateHints` to the normalized populate tree.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyPopulateHints<Entity>(populate: PopulateOptions<Entity>[], hints: Record<string, PopulateHintOptions>): void;
|
package/entity/utils.js
CHANGED
|
@@ -67,3 +67,36 @@ export function getLoadingStrategy(strategy, kind) {
|
|
|
67
67
|
}
|
|
68
68
|
return strategy;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Applies per-relation overrides from `populateHints` to the normalized populate tree.
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export function applyPopulateHints(populate, hints) {
|
|
75
|
+
for (const [path, hint] of Object.entries(hints)) {
|
|
76
|
+
const entry = findPopulateEntry(populate, path.split('.'));
|
|
77
|
+
if (!entry) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (hint.strategy != null) {
|
|
81
|
+
entry.strategy = hint.strategy;
|
|
82
|
+
}
|
|
83
|
+
if (hint.joinType != null) {
|
|
84
|
+
entry.joinType = hint.joinType;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function findPopulateEntry(populate, parts) {
|
|
89
|
+
let current = populate;
|
|
90
|
+
for (let i = 0; i < parts.length; i++) {
|
|
91
|
+
const entry = current.find(p => p.field.split(':')[0] === parts[i]);
|
|
92
|
+
if (!entry) {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
if (i === parts.length - 1) {
|
|
96
|
+
return entry;
|
|
97
|
+
}
|
|
98
|
+
current = (entry.children ?? []);
|
|
99
|
+
}
|
|
100
|
+
/* v8 ignore next */
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module core
|
|
4
4
|
*/
|
|
5
5
|
export { EntityMetadata, PrimaryKeyProp, EntityRepositoryType, OptionalProps, EagerProps, HiddenProps, Config } from './typings.js';
|
|
6
|
-
export type { CompiledFunctions, Constructor, ConnectionType, Dictionary, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, RequiredEntityData, CheckCallback, IndexCallback, FormulaCallback, FormulaTable, SchemaTable, SchemaColumns, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, EntityType, FromEntityType, Selected, IsSubset, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, FilterValue, MergeLoaded, MergeSelected, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, DefineConfig, Opt, Hidden, EntitySchemaWithMeta, InferEntity, CheckConstraint, GeneratedColumnCallback, FilterDef, EntityCtor, Subquery, } from './typings.js';
|
|
6
|
+
export type { CompiledFunctions, Constructor, ConnectionType, Dictionary, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, RequiredEntityData, CheckCallback, IndexCallback, FormulaCallback, FormulaTable, SchemaTable, SchemaColumns, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, EntityType, FromEntityType, Selected, IsSubset, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, FilterValue, MergeLoaded, MergeSelected, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, DefineConfig, Opt, Hidden, EntitySchemaWithMeta, InferEntity, CheckConstraint, GeneratedColumnCallback, FilterDef, EntityCtor, Subquery, PopulateHintOptions, Prefixes, } from './typings.js';
|
|
7
7
|
export * from './enums.js';
|
|
8
8
|
export * from './errors.js';
|
|
9
9
|
export * from './exceptions.js';
|
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-rc.
|
|
4
|
+
"version": "7.0.0-rc.1",
|
|
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/typings.d.ts
CHANGED
|
@@ -151,7 +151,7 @@ declare const __loadHint: unique symbol;
|
|
|
151
151
|
* This reflects that loading 'a.b.c' means 'a' and 'a.b' are also loaded.
|
|
152
152
|
* Special case: '*' returns string to ensure Loaded<T, '*'> is assignable to any Loaded<T, Hint>.
|
|
153
153
|
*/
|
|
154
|
-
type Prefixes<S extends string> = S extends '*' ? string : S extends `${infer H}.${infer T}` ? H | `${H}.${Prefixes<T>}` : S;
|
|
154
|
+
export type Prefixes<S extends string> = S extends '*' ? string : S extends `${infer H}.${infer T}` ? H | `${H}.${Prefixes<T>}` : S;
|
|
155
155
|
export type UnwrapPrimary<T> = T extends Scalar ? T : T extends ReferenceShape<infer U> ? Primary<U> : Primary<T>;
|
|
156
156
|
type PrimaryPropToType<T, Keys extends (keyof T)[]> = {
|
|
157
157
|
[Index in keyof Keys]: UnwrapPrimary<T[Keys[Index]]>;
|
|
@@ -335,7 +335,7 @@ type ExplicitlyOptionalProps<T> = (T extends {
|
|
|
335
335
|
[K in keyof T]: T[K] extends Opt ? K : never;
|
|
336
336
|
}[keyof T] & {});
|
|
337
337
|
type NullableKeys<T, V = null> = {
|
|
338
|
-
[K in keyof T]: V extends T[K] ? K : never;
|
|
338
|
+
[K in keyof T]: unknown extends T[K] ? never : V extends T[K] ? K : never;
|
|
339
339
|
}[keyof T];
|
|
340
340
|
type RequiredNullableKeys<T> = {
|
|
341
341
|
[K in keyof T]: Exclude<T[K], null> extends RequiredNullable.Brand ? K : never;
|
|
@@ -924,6 +924,10 @@ export type PopulateOptions<T> = {
|
|
|
924
924
|
/** When true, ignores `mapToPk` on the property and returns full entity data instead of just PKs. */
|
|
925
925
|
dataOnly?: boolean;
|
|
926
926
|
};
|
|
927
|
+
export type PopulateHintOptions = {
|
|
928
|
+
strategy?: LoadStrategy.JOINED | LoadStrategy.SELECT_IN | 'joined' | 'select-in';
|
|
929
|
+
joinType?: 'inner join' | 'left join';
|
|
930
|
+
};
|
|
927
931
|
type ExtractType<T> = T extends CollectionShape<infer U> ? U : T extends ReferenceShape<infer U> ? U : T extends Ref<infer U> ? U : T extends readonly (infer U)[] ? U : T;
|
|
928
932
|
type ExtractStringKeys<T> = {
|
|
929
933
|
[K in keyof T]-?: CleanKeys<T, K>;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { type Configuration } from '../utils/Configuration.js';
|
|
2
|
-
import type { MetadataStorage } from '../metadata/MetadataStorage.js';
|
|
3
1
|
import type { AnyEntity } from '../typings.js';
|
|
4
2
|
import { ChangeSet } from './ChangeSet.js';
|
|
5
3
|
import { type Collection } from '../entity/Collection.js';
|
|
6
|
-
import type { Platform } from '../platforms/Platform.js';
|
|
7
4
|
import type { EntityManager } from '../EntityManager.js';
|
|
8
5
|
export declare class ChangeSetComputer {
|
|
6
|
+
private readonly em;
|
|
9
7
|
private readonly collectionUpdates;
|
|
8
|
+
private readonly comparator;
|
|
10
9
|
private readonly metadata;
|
|
11
10
|
private readonly platform;
|
|
12
11
|
private readonly config;
|
|
13
|
-
|
|
14
|
-
private readonly comparator;
|
|
15
|
-
constructor(collectionUpdates: Set<Collection<AnyEntity>>, metadata: MetadataStorage, platform: Platform, config: Configuration, em: EntityManager);
|
|
12
|
+
constructor(em: EntityManager, collectionUpdates: Set<Collection<AnyEntity>>);
|
|
16
13
|
computeChangeSet<T extends object>(entity: T): ChangeSet<T> | null;
|
|
17
14
|
/**
|
|
18
15
|
* Traverses entity graph and executes `onCreate` and `onUpdate` methods, assigning the values to given properties.
|
|
@@ -7,18 +7,18 @@ import { Reference } from '../entity/Reference.js';
|
|
|
7
7
|
import { PolymorphicRef } from '../entity/PolymorphicRef.js';
|
|
8
8
|
import { ReferenceKind } from '../enums.js';
|
|
9
9
|
export class ChangeSetComputer {
|
|
10
|
+
em;
|
|
10
11
|
collectionUpdates;
|
|
12
|
+
comparator;
|
|
11
13
|
metadata;
|
|
12
14
|
platform;
|
|
13
15
|
config;
|
|
14
|
-
em
|
|
15
|
-
comparator;
|
|
16
|
-
constructor(collectionUpdates, metadata, platform, config, em) {
|
|
17
|
-
this.collectionUpdates = collectionUpdates;
|
|
18
|
-
this.metadata = metadata;
|
|
19
|
-
this.platform = platform;
|
|
20
|
-
this.config = config;
|
|
16
|
+
constructor(em, collectionUpdates) {
|
|
21
17
|
this.em = em;
|
|
18
|
+
this.collectionUpdates = collectionUpdates;
|
|
19
|
+
this.config = this.em.config;
|
|
20
|
+
this.metadata = this.em.getMetadata();
|
|
21
|
+
this.platform = this.em.getPlatform();
|
|
22
22
|
this.comparator = this.config.getComparator(this.metadata);
|
|
23
23
|
}
|
|
24
24
|
computeChangeSet(entity) {
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Dictionary, EntityDictionary, EntityMetadata, IHydrator } from '../typings.js';
|
|
3
|
-
import { type EntityFactory } from '../entity/EntityFactory.js';
|
|
1
|
+
import type { Dictionary, EntityDictionary, EntityMetadata } from '../typings.js';
|
|
4
2
|
import { type ChangeSet } from './ChangeSet.js';
|
|
5
|
-
import {
|
|
6
|
-
import type { DriverMethodOptions, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
|
|
3
|
+
import type { DriverMethodOptions } from '../drivers/IDatabaseDriver.js';
|
|
7
4
|
import type { EntityManager } from '../EntityManager.js';
|
|
8
5
|
export declare class ChangeSetPersister {
|
|
6
|
+
private readonly em;
|
|
7
|
+
private readonly platform;
|
|
8
|
+
private readonly comparator;
|
|
9
|
+
private readonly usesReturningStatement;
|
|
9
10
|
private readonly driver;
|
|
10
11
|
private readonly metadata;
|
|
11
12
|
private readonly hydrator;
|
|
12
13
|
private readonly factory;
|
|
13
14
|
private readonly config;
|
|
14
|
-
|
|
15
|
-
private readonly platform;
|
|
16
|
-
private readonly comparator;
|
|
17
|
-
private readonly usesReturningStatement;
|
|
18
|
-
constructor(driver: IDatabaseDriver, metadata: MetadataStorage, hydrator: IHydrator, factory: EntityFactory, config: Configuration, em: EntityManager);
|
|
15
|
+
constructor(em: EntityManager);
|
|
19
16
|
executeInserts<T extends object>(changeSets: ChangeSet<T>[], options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
|
|
20
17
|
executeUpdates<T extends object>(changeSets: ChangeSet<T>[], batched: boolean, options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
|
|
21
18
|
executeDeletes<T extends object>(changeSets: ChangeSet<T>[], options?: DriverMethodOptions, withSchema?: boolean): Promise<void>;
|
|
@@ -7,23 +7,23 @@ import { Utils } from '../utils/Utils.js';
|
|
|
7
7
|
import { OptimisticLockError, ValidationError } from '../errors.js';
|
|
8
8
|
import { ReferenceKind } from '../enums.js';
|
|
9
9
|
export class ChangeSetPersister {
|
|
10
|
+
em;
|
|
11
|
+
platform;
|
|
12
|
+
comparator;
|
|
13
|
+
usesReturningStatement;
|
|
10
14
|
driver;
|
|
11
15
|
metadata;
|
|
12
16
|
hydrator;
|
|
13
17
|
factory;
|
|
14
18
|
config;
|
|
15
|
-
em
|
|
16
|
-
platform;
|
|
17
|
-
comparator;
|
|
18
|
-
usesReturningStatement;
|
|
19
|
-
constructor(driver, metadata, hydrator, factory, config, em) {
|
|
20
|
-
this.driver = driver;
|
|
21
|
-
this.metadata = metadata;
|
|
22
|
-
this.hydrator = hydrator;
|
|
23
|
-
this.factory = factory;
|
|
24
|
-
this.config = config;
|
|
19
|
+
constructor(em) {
|
|
25
20
|
this.em = em;
|
|
21
|
+
this.driver = this.em.getDriver();
|
|
22
|
+
this.config = this.em.config;
|
|
23
|
+
this.metadata = this.em.getMetadata();
|
|
24
|
+
this.factory = this.em.getEntityFactory();
|
|
26
25
|
this.platform = this.driver.getPlatform();
|
|
26
|
+
this.hydrator = this.config.getHydrator(this.metadata);
|
|
27
27
|
this.comparator = this.config.getComparator(this.metadata);
|
|
28
28
|
this.usesReturningStatement = this.platform.usesReturningStatement() || this.platform.usesOutputStatement();
|
|
29
29
|
}
|
|
@@ -42,8 +42,8 @@ export class UnitOfWork {
|
|
|
42
42
|
this.identityMap = new IdentityMap(this.platform.getDefaultSchemaName());
|
|
43
43
|
this.eventManager = this.em.getEventManager();
|
|
44
44
|
this.comparator = this.em.getComparator();
|
|
45
|
-
this.changeSetComputer = new ChangeSetComputer(this.
|
|
46
|
-
this.changeSetPersister = new ChangeSetPersister(this.em
|
|
45
|
+
this.changeSetComputer = new ChangeSetComputer(this.em, this.collectionUpdates);
|
|
46
|
+
this.changeSetPersister = new ChangeSetPersister(this.em);
|
|
47
47
|
}
|
|
48
48
|
merge(entity, visited) {
|
|
49
49
|
const wrapped = helper(entity);
|
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-rc.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-rc.1';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|
package/utils/fs-utils.js
CHANGED
|
@@ -77,8 +77,8 @@ export const fs = {
|
|
|
77
77
|
getPackageConfig(basePath = process.cwd()) {
|
|
78
78
|
if (this.pathExists(`${basePath}/package.json`)) {
|
|
79
79
|
try {
|
|
80
|
-
const path = import.meta.resolve(`${basePath}/package.json`);
|
|
81
|
-
return this.readJSONSync(
|
|
80
|
+
const path = this.normalizePath(import.meta.resolve(`${basePath}/package.json`));
|
|
81
|
+
return this.readJSONSync(path);
|
|
82
82
|
}
|
|
83
83
|
catch (e) {
|
|
84
84
|
/* v8 ignore next */
|