@mikro-orm/core 7.0.0-dev.50 → 7.0.0-dev.52
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/MikroORM.d.ts +2 -2
- package/package.json +2 -2
- package/utils/Configuration.d.ts +191 -187
- package/utils/Configuration.js +131 -137
- package/utils/ConfigurationLoader.d.ts +1 -1
- package/utils/Utils.d.ts +1 -1
- package/utils/Utils.js +6 -9
package/MikroORM.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { AnyEntity, Constructor, EntityClass, EntityMetadata, EntityName, I
|
|
|
7
7
|
/**
|
|
8
8
|
* Helper class for bootstrapping the MikroORM.
|
|
9
9
|
*/
|
|
10
|
-
export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = Driver[typeof EntityManagerType] & EntityManager
|
|
10
|
+
export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends Driver[typeof EntityManagerType] & EntityManager<Driver> = Driver[typeof EntityManagerType] & EntityManager<Driver>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> {
|
|
11
11
|
/** The global EntityManager instance. If you are using `RequestContext` helper, it will automatically pick the request specific context under the hood */
|
|
12
12
|
em: EM & {
|
|
13
13
|
'~entities'?: Entities;
|
|
@@ -21,7 +21,7 @@ export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver,
|
|
|
21
21
|
* Initialize the ORM, load entity metadata, create EntityManager and connect to the database.
|
|
22
22
|
* If you omit the `options` parameter, your CLI config will be used.
|
|
23
23
|
*/
|
|
24
|
-
static init<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager
|
|
24
|
+
static init<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Promise<MikroORM<D, EM, Entities>>;
|
|
25
25
|
/**
|
|
26
26
|
* Synchronous variant of the `init` method with some limitations:
|
|
27
27
|
* - database connection will be established when you first interact with the database (or you can use `orm.connect()` explicitly)
|
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.
|
|
4
|
+
"version": "7.0.0-dev.52",
|
|
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",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dataloader": "2.2.3",
|
|
55
55
|
"dotenv": "17.2.3",
|
|
56
56
|
"esprima": "4.0.1",
|
|
57
|
-
"mikro-orm": "7.0.0-dev.
|
|
57
|
+
"mikro-orm": "7.0.0-dev.52",
|
|
58
58
|
"reflect-metadata": "0.2.2",
|
|
59
59
|
"tinyglobby": "0.2.13"
|
|
60
60
|
}
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -22,134 +22,134 @@ import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
|
|
|
22
22
|
import { EntityComparator } from './EntityComparator.js';
|
|
23
23
|
import type { Type } from '../types/Type.js';
|
|
24
24
|
import type { MikroORM } from '../MikroORM.js';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
cacheDir: string;
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
resultCache: {
|
|
137
|
-
adapter: typeof MemoryCacheAdapter;
|
|
138
|
-
expiration: number;
|
|
139
|
-
options: {};
|
|
140
|
-
};
|
|
141
|
-
metadataProvider: typeof ReflectMetadataProvider;
|
|
142
|
-
highlighter: NullHighlighter;
|
|
143
|
-
seeder: {
|
|
144
|
-
path: string;
|
|
145
|
-
defaultSeeder: string;
|
|
146
|
-
glob: string;
|
|
147
|
-
emit: "ts";
|
|
148
|
-
fileName: (className: string) => string;
|
|
25
|
+
declare const DEFAULTS: {
|
|
26
|
+
readonly pool: {};
|
|
27
|
+
readonly entities: readonly [];
|
|
28
|
+
readonly entitiesTs: readonly [];
|
|
29
|
+
readonly extensions: readonly [];
|
|
30
|
+
readonly subscribers: readonly [];
|
|
31
|
+
readonly filters: {};
|
|
32
|
+
readonly discovery: {
|
|
33
|
+
readonly warnWhenNoEntities: true;
|
|
34
|
+
readonly requireEntitiesArray: false;
|
|
35
|
+
readonly checkDuplicateTableNames: true;
|
|
36
|
+
readonly checkDuplicateFieldNames: true;
|
|
37
|
+
readonly checkDuplicateEntities: true;
|
|
38
|
+
readonly checkNonPersistentCompositeProps: true;
|
|
39
|
+
readonly alwaysAnalyseProperties: true;
|
|
40
|
+
readonly disableDynamicFileAccess: false;
|
|
41
|
+
readonly inferDefaultValues: true;
|
|
42
|
+
};
|
|
43
|
+
readonly strict: false;
|
|
44
|
+
readonly validate: false;
|
|
45
|
+
readonly validateRequired: true;
|
|
46
|
+
readonly context: (name: string) => EntityManager<IDatabaseDriver<import("../index.js").Connection>> | undefined;
|
|
47
|
+
readonly contextName: "default";
|
|
48
|
+
readonly allowGlobalContext: false;
|
|
49
|
+
readonly logger: (message?: any, ...optionalParams: any[]) => void;
|
|
50
|
+
readonly colors: true;
|
|
51
|
+
readonly findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
|
|
52
|
+
readonly findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
|
|
53
|
+
readonly baseDir: string;
|
|
54
|
+
readonly hydrator: typeof ObjectHydrator;
|
|
55
|
+
readonly flushMode: FlushMode.AUTO;
|
|
56
|
+
readonly loadStrategy: LoadStrategy.BALANCED;
|
|
57
|
+
readonly dataloader: DataloaderType.NONE;
|
|
58
|
+
readonly populateWhere: PopulateHint.ALL;
|
|
59
|
+
readonly ignoreUndefinedInQuery: false;
|
|
60
|
+
readonly onQuery: (sql: string) => string;
|
|
61
|
+
readonly autoJoinOneToOneOwner: true;
|
|
62
|
+
readonly autoJoinRefsForFilters: true;
|
|
63
|
+
readonly filtersOnRelations: true;
|
|
64
|
+
readonly propagationOnPrototype: true;
|
|
65
|
+
readonly populateAfterFlush: true;
|
|
66
|
+
readonly serialization: {
|
|
67
|
+
readonly includePrimaryKeys: true;
|
|
68
|
+
};
|
|
69
|
+
readonly assign: {
|
|
70
|
+
readonly updateNestedEntities: true;
|
|
71
|
+
readonly updateByPrimaryKey: true;
|
|
72
|
+
readonly mergeObjectProperties: false;
|
|
73
|
+
readonly mergeEmbeddedProperties: true;
|
|
74
|
+
readonly ignoreUndefined: false;
|
|
75
|
+
};
|
|
76
|
+
readonly persistOnCreate: true;
|
|
77
|
+
readonly upsertManaged: true;
|
|
78
|
+
readonly forceEntityConstructor: false;
|
|
79
|
+
readonly forceUndefined: false;
|
|
80
|
+
readonly processOnCreateHooksEarly: false;
|
|
81
|
+
readonly ensureDatabase: true;
|
|
82
|
+
readonly ensureIndexes: false;
|
|
83
|
+
readonly batchSize: 300;
|
|
84
|
+
readonly hashAlgorithm: "md5";
|
|
85
|
+
readonly debug: false;
|
|
86
|
+
readonly ignoreDeprecations: false;
|
|
87
|
+
readonly verbose: false;
|
|
88
|
+
readonly driverOptions: {};
|
|
89
|
+
readonly migrations: {
|
|
90
|
+
readonly tableName: "mikro_orm_migrations";
|
|
91
|
+
readonly path: "./migrations";
|
|
92
|
+
readonly glob: "!(*.d).{js,ts,cjs}";
|
|
93
|
+
readonly silent: false;
|
|
94
|
+
readonly transactional: true;
|
|
95
|
+
readonly disableForeignKeys: false;
|
|
96
|
+
readonly allOrNothing: true;
|
|
97
|
+
readonly dropTables: true;
|
|
98
|
+
readonly safe: false;
|
|
99
|
+
readonly snapshot: true;
|
|
100
|
+
readonly emit: "ts";
|
|
101
|
+
readonly fileName: (timestamp: string, name?: string) => string;
|
|
102
|
+
};
|
|
103
|
+
readonly schemaGenerator: {
|
|
104
|
+
readonly disableForeignKeys: false;
|
|
105
|
+
readonly createForeignKeyConstraints: true;
|
|
106
|
+
readonly ignoreSchema: readonly [];
|
|
107
|
+
readonly skipTables: readonly [];
|
|
108
|
+
readonly skipColumns: {};
|
|
109
|
+
};
|
|
110
|
+
readonly embeddables: {
|
|
111
|
+
readonly prefixMode: "relative";
|
|
112
|
+
};
|
|
113
|
+
readonly entityGenerator: {
|
|
114
|
+
readonly forceUndefined: true;
|
|
115
|
+
readonly undefinedDefaults: false;
|
|
116
|
+
readonly scalarTypeInDecorator: false;
|
|
117
|
+
readonly bidirectionalRelations: true;
|
|
118
|
+
readonly identifiedReferences: true;
|
|
119
|
+
readonly scalarPropertiesForRelations: "never";
|
|
120
|
+
readonly entityDefinition: "defineEntity";
|
|
121
|
+
readonly enumMode: "dictionary";
|
|
122
|
+
readonly fileName: (className: string) => string;
|
|
123
|
+
readonly onlyPurePivotTables: false;
|
|
124
|
+
readonly outputPurePivotTables: false;
|
|
125
|
+
readonly readOnlyPivotTables: false;
|
|
126
|
+
readonly useCoreBaseEntity: false;
|
|
127
|
+
};
|
|
128
|
+
readonly metadataCache: {
|
|
129
|
+
readonly pretty: false;
|
|
130
|
+
readonly adapter: typeof FileCacheAdapter;
|
|
131
|
+
readonly options: {
|
|
132
|
+
readonly cacheDir: string;
|
|
149
133
|
};
|
|
150
|
-
preferReadReplicas: true;
|
|
151
|
-
dynamicImportProvider: (id: string) => Promise<any>;
|
|
152
134
|
};
|
|
135
|
+
readonly resultCache: {
|
|
136
|
+
readonly adapter: typeof MemoryCacheAdapter;
|
|
137
|
+
readonly expiration: 1000;
|
|
138
|
+
readonly options: {};
|
|
139
|
+
};
|
|
140
|
+
readonly metadataProvider: typeof ReflectMetadataProvider;
|
|
141
|
+
readonly highlighter: NullHighlighter;
|
|
142
|
+
readonly seeder: {
|
|
143
|
+
readonly path: "./seeders";
|
|
144
|
+
readonly defaultSeeder: "DatabaseSeeder";
|
|
145
|
+
readonly glob: "!(*.d).{js,ts}";
|
|
146
|
+
readonly emit: "ts";
|
|
147
|
+
readonly fileName: (className: string) => string;
|
|
148
|
+
};
|
|
149
|
+
readonly preferReadReplicas: true;
|
|
150
|
+
readonly dynamicImportProvider: (id: string) => Promise<any>;
|
|
151
|
+
};
|
|
152
|
+
export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>> {
|
|
153
153
|
private readonly options;
|
|
154
154
|
private readonly logger;
|
|
155
155
|
private readonly driver;
|
|
@@ -161,16 +161,16 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
161
161
|
/**
|
|
162
162
|
* Gets specific configuration option. Falls back to specified `defaultValue` if provided.
|
|
163
163
|
*/
|
|
164
|
-
get<T extends keyof
|
|
165
|
-
getAll():
|
|
164
|
+
get<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
|
|
165
|
+
getAll(): RequiredOptions<D, EM>;
|
|
166
166
|
/**
|
|
167
167
|
* Overrides specified configuration value.
|
|
168
168
|
*/
|
|
169
|
-
set<T extends keyof
|
|
169
|
+
set<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, value: U): void;
|
|
170
170
|
/**
|
|
171
171
|
* Resets the configuration to its default value
|
|
172
172
|
*/
|
|
173
|
-
reset<T extends keyof
|
|
173
|
+
reset<T extends keyof RequiredOptions<D, EM>>(key: T): void;
|
|
174
174
|
/**
|
|
175
175
|
* Gets Logger instance.
|
|
176
176
|
*/
|
|
@@ -210,7 +210,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
210
210
|
/**
|
|
211
211
|
* Gets EntityRepository class to be instantiated.
|
|
212
212
|
*/
|
|
213
|
-
getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>):
|
|
213
|
+
getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): Options<D, EM>['entityRepository'];
|
|
214
214
|
/**
|
|
215
215
|
* Creates instance of given service and caches it.
|
|
216
216
|
*/
|
|
@@ -298,87 +298,87 @@ export interface MetadataDiscoveryOptions {
|
|
|
298
298
|
tsConfigPath?: string;
|
|
299
299
|
skipSyncDiscovery?: boolean;
|
|
300
300
|
}
|
|
301
|
-
export interface
|
|
302
|
-
entities
|
|
303
|
-
entitiesTs
|
|
304
|
-
extensions
|
|
301
|
+
export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<Driver> & Driver[typeof EntityManagerType] = EntityManager<Driver> & Driver[typeof EntityManagerType], Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends ConnectionOptions {
|
|
302
|
+
entities?: Entities;
|
|
303
|
+
entitiesTs?: (string | EntityClass<AnyEntity> | EntitySchema)[];
|
|
304
|
+
extensions?: {
|
|
305
305
|
register: (orm: MikroORM) => void;
|
|
306
306
|
}[];
|
|
307
|
-
subscribers
|
|
308
|
-
filters
|
|
307
|
+
subscribers?: (EventSubscriber | Constructor<EventSubscriber>)[];
|
|
308
|
+
filters?: Dictionary<{
|
|
309
309
|
name?: string;
|
|
310
310
|
} & Omit<FilterDef, 'name'>>;
|
|
311
|
-
discovery
|
|
311
|
+
discovery?: MetadataDiscoveryOptions;
|
|
312
312
|
driver?: {
|
|
313
|
-
new (config: Configuration):
|
|
313
|
+
new (config: Configuration): Driver;
|
|
314
314
|
};
|
|
315
315
|
namingStrategy?: {
|
|
316
316
|
new (): NamingStrategy;
|
|
317
317
|
};
|
|
318
318
|
implicitTransactions?: boolean;
|
|
319
319
|
disableTransactions?: boolean;
|
|
320
|
-
verbose
|
|
320
|
+
verbose?: boolean;
|
|
321
321
|
ignoreUndefinedInQuery?: boolean;
|
|
322
|
-
onQuery
|
|
323
|
-
autoJoinOneToOneOwner
|
|
324
|
-
autoJoinRefsForFilters
|
|
325
|
-
filtersOnRelations
|
|
326
|
-
propagationOnPrototype
|
|
327
|
-
populateAfterFlush
|
|
328
|
-
serialization
|
|
322
|
+
onQuery?: (sql: string, params: readonly unknown[]) => string;
|
|
323
|
+
autoJoinOneToOneOwner?: boolean;
|
|
324
|
+
autoJoinRefsForFilters?: boolean;
|
|
325
|
+
filtersOnRelations?: boolean;
|
|
326
|
+
propagationOnPrototype?: boolean;
|
|
327
|
+
populateAfterFlush?: boolean;
|
|
328
|
+
serialization?: {
|
|
329
329
|
includePrimaryKeys?: boolean;
|
|
330
330
|
/** Enforce unpopulated references to be returned as objects, e.g. `{ author: { id: 1 } }` instead of `{ author: 1 }`. */
|
|
331
331
|
forceObject?: boolean;
|
|
332
332
|
};
|
|
333
|
-
assign
|
|
334
|
-
persistOnCreate
|
|
335
|
-
upsertManaged
|
|
336
|
-
forceEntityConstructor
|
|
337
|
-
forceUndefined
|
|
333
|
+
assign?: AssignOptions<boolean>;
|
|
334
|
+
persistOnCreate?: boolean;
|
|
335
|
+
upsertManaged?: boolean;
|
|
336
|
+
forceEntityConstructor?: boolean | (Constructor<AnyEntity> | string)[];
|
|
337
|
+
forceUndefined?: boolean;
|
|
338
338
|
/**
|
|
339
339
|
* Property `onCreate` hooks are normally executed during `flush` operation.
|
|
340
340
|
* With this option, they will be processed early inside `em.create()` method.
|
|
341
341
|
*/
|
|
342
|
-
processOnCreateHooksEarly
|
|
342
|
+
processOnCreateHooksEarly?: boolean;
|
|
343
343
|
forceUtcTimezone?: boolean;
|
|
344
344
|
timezone?: string;
|
|
345
|
-
ensureDatabase
|
|
346
|
-
ensureIndexes
|
|
345
|
+
ensureDatabase?: boolean | EnsureDatabaseOptions;
|
|
346
|
+
ensureIndexes?: boolean;
|
|
347
347
|
useBatchInserts?: boolean;
|
|
348
348
|
useBatchUpdates?: boolean;
|
|
349
|
-
batchSize
|
|
350
|
-
hydrator
|
|
351
|
-
loadStrategy
|
|
352
|
-
dataloader
|
|
349
|
+
batchSize?: number;
|
|
350
|
+
hydrator?: HydratorConstructor;
|
|
351
|
+
loadStrategy?: LoadStrategy | `${LoadStrategy}`;
|
|
352
|
+
dataloader?: DataloaderType | boolean;
|
|
353
353
|
populateWhere?: PopulateHint | `${PopulateHint}`;
|
|
354
|
-
flushMode
|
|
354
|
+
flushMode?: FlushMode | `${FlushMode}`;
|
|
355
355
|
entityRepository?: EntityClass<EntityRepository<any>>;
|
|
356
356
|
entityManager?: Constructor<EM>;
|
|
357
357
|
replicas?: ConnectionOptions[];
|
|
358
|
-
strict
|
|
359
|
-
validate
|
|
360
|
-
validateRequired
|
|
361
|
-
context
|
|
362
|
-
contextName
|
|
363
|
-
allowGlobalContext
|
|
358
|
+
strict?: boolean;
|
|
359
|
+
validate?: boolean;
|
|
360
|
+
validateRequired?: boolean;
|
|
361
|
+
context?: (name: string) => EntityManager | undefined;
|
|
362
|
+
contextName?: string;
|
|
363
|
+
allowGlobalContext?: boolean;
|
|
364
364
|
disableIdentityMap?: boolean;
|
|
365
|
-
logger
|
|
365
|
+
logger?: (message: string) => void;
|
|
366
366
|
colors?: boolean;
|
|
367
367
|
loggerFactory?: (options: LoggerOptions) => Logger;
|
|
368
|
-
findOneOrFailHandler
|
|
369
|
-
findExactlyOneOrFailHandler
|
|
370
|
-
debug
|
|
371
|
-
ignoreDeprecations
|
|
372
|
-
highlighter
|
|
368
|
+
findOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
|
|
369
|
+
findExactlyOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
|
|
370
|
+
debug?: boolean | LoggerNamespace[];
|
|
371
|
+
ignoreDeprecations?: boolean | string[];
|
|
372
|
+
highlighter?: Highlighter;
|
|
373
373
|
/**
|
|
374
374
|
* Using this option, you can force the ORM to use the TS options regardless of whether the TypeScript support
|
|
375
375
|
* is detected or not. This effectively means using `entitiesTs` for discovery and `pathTs` for migrations and
|
|
376
376
|
* seeders. Should be used only for tests and stay disabled for production builds.
|
|
377
377
|
*/
|
|
378
378
|
preferTs?: boolean;
|
|
379
|
-
baseDir
|
|
380
|
-
migrations
|
|
381
|
-
schemaGenerator
|
|
379
|
+
baseDir?: string;
|
|
380
|
+
migrations?: MigrationsOptions;
|
|
381
|
+
schemaGenerator?: {
|
|
382
382
|
disableForeignKeys?: boolean;
|
|
383
383
|
createForeignKeyConstraints?: boolean;
|
|
384
384
|
ignoreSchema?: string[];
|
|
@@ -386,11 +386,11 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
386
386
|
skipColumns?: Dictionary<(string | RegExp)[]>;
|
|
387
387
|
managementDbName?: string;
|
|
388
388
|
};
|
|
389
|
-
embeddables
|
|
389
|
+
embeddables?: {
|
|
390
390
|
prefixMode: EmbeddedPrefixMode;
|
|
391
391
|
};
|
|
392
|
-
entityGenerator
|
|
393
|
-
metadataCache
|
|
392
|
+
entityGenerator?: GenerateOptions;
|
|
393
|
+
metadataCache?: {
|
|
394
394
|
enabled?: boolean;
|
|
395
395
|
combined?: boolean | string;
|
|
396
396
|
pretty?: boolean;
|
|
@@ -399,7 +399,7 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
399
399
|
};
|
|
400
400
|
options?: Dictionary;
|
|
401
401
|
};
|
|
402
|
-
resultCache
|
|
402
|
+
resultCache?: {
|
|
403
403
|
expiration?: number;
|
|
404
404
|
adapter?: {
|
|
405
405
|
new (...params: any[]): CacheAdapter;
|
|
@@ -407,14 +407,18 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
407
407
|
options?: Dictionary;
|
|
408
408
|
global?: boolean | number | [string, number];
|
|
409
409
|
};
|
|
410
|
-
metadataProvider
|
|
410
|
+
metadataProvider?: {
|
|
411
411
|
new (config: Configuration): MetadataProvider;
|
|
412
412
|
};
|
|
413
|
-
seeder
|
|
414
|
-
preferReadReplicas
|
|
415
|
-
dynamicImportProvider
|
|
416
|
-
hashAlgorithm
|
|
417
|
-
}
|
|
418
|
-
export interface Options<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = D[typeof EntityManagerType] & EntityManager, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends Pick<MikroORMOptions<D, EM>, Exclude<keyof MikroORMOptions, keyof typeof Configuration.DEFAULTS>>, Partial<MikroORMOptions<D, EM>> {
|
|
419
|
-
entities?: Entities;
|
|
413
|
+
seeder?: SeederOptions;
|
|
414
|
+
preferReadReplicas?: boolean;
|
|
415
|
+
dynamicImportProvider?: (id: string) => Promise<unknown>;
|
|
416
|
+
hashAlgorithm?: 'md5' | 'sha256';
|
|
420
417
|
}
|
|
418
|
+
type MarkRequired<T, D> = {
|
|
419
|
+
[K in keyof T as Extract<K, keyof D>]-?: T[K];
|
|
420
|
+
} & {
|
|
421
|
+
[K in keyof T as Exclude<K, keyof D>]?: T[K];
|
|
422
|
+
};
|
|
423
|
+
export type RequiredOptions<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = MarkRequired<Options<D, EM, Entities>, typeof DEFAULTS>;
|
|
424
|
+
export {};
|
package/utils/Configuration.js
CHANGED
|
@@ -11,133 +11,133 @@ import { RequestContext } from './RequestContext.js';
|
|
|
11
11
|
import { DataloaderType, FlushMode, LoadStrategy, PopulateHint } from '../enums.js';
|
|
12
12
|
import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
|
|
13
13
|
import { EntityComparator } from './EntityComparator.js';
|
|
14
|
+
const DEFAULTS = {
|
|
15
|
+
pool: {},
|
|
16
|
+
entities: [],
|
|
17
|
+
entitiesTs: [],
|
|
18
|
+
extensions: [],
|
|
19
|
+
subscribers: [],
|
|
20
|
+
filters: {},
|
|
21
|
+
discovery: {
|
|
22
|
+
warnWhenNoEntities: true,
|
|
23
|
+
requireEntitiesArray: false,
|
|
24
|
+
checkDuplicateTableNames: true,
|
|
25
|
+
checkDuplicateFieldNames: true,
|
|
26
|
+
checkDuplicateEntities: true,
|
|
27
|
+
checkNonPersistentCompositeProps: true,
|
|
28
|
+
alwaysAnalyseProperties: true,
|
|
29
|
+
disableDynamicFileAccess: false,
|
|
30
|
+
inferDefaultValues: true,
|
|
31
|
+
},
|
|
32
|
+
strict: false,
|
|
33
|
+
validate: false,
|
|
34
|
+
validateRequired: true,
|
|
35
|
+
context: (name) => RequestContext.getEntityManager(name),
|
|
36
|
+
contextName: 'default',
|
|
37
|
+
allowGlobalContext: false,
|
|
38
|
+
// eslint-disable-next-line no-console
|
|
39
|
+
logger: console.log.bind(console),
|
|
40
|
+
colors: true,
|
|
41
|
+
findOneOrFailHandler: (entityName, where) => NotFoundError.findOneFailed(entityName, where),
|
|
42
|
+
findExactlyOneOrFailHandler: (entityName, where) => NotFoundError.findExactlyOneFailed(entityName, where),
|
|
43
|
+
baseDir: process.cwd(),
|
|
44
|
+
hydrator: ObjectHydrator,
|
|
45
|
+
flushMode: FlushMode.AUTO,
|
|
46
|
+
loadStrategy: LoadStrategy.BALANCED,
|
|
47
|
+
dataloader: DataloaderType.NONE,
|
|
48
|
+
populateWhere: PopulateHint.ALL,
|
|
49
|
+
ignoreUndefinedInQuery: false,
|
|
50
|
+
onQuery: (sql) => sql,
|
|
51
|
+
autoJoinOneToOneOwner: true,
|
|
52
|
+
autoJoinRefsForFilters: true,
|
|
53
|
+
filtersOnRelations: true,
|
|
54
|
+
propagationOnPrototype: true,
|
|
55
|
+
populateAfterFlush: true,
|
|
56
|
+
serialization: {
|
|
57
|
+
includePrimaryKeys: true,
|
|
58
|
+
},
|
|
59
|
+
assign: {
|
|
60
|
+
updateNestedEntities: true,
|
|
61
|
+
updateByPrimaryKey: true,
|
|
62
|
+
mergeObjectProperties: false,
|
|
63
|
+
mergeEmbeddedProperties: true,
|
|
64
|
+
ignoreUndefined: false,
|
|
65
|
+
},
|
|
66
|
+
persistOnCreate: true,
|
|
67
|
+
upsertManaged: true,
|
|
68
|
+
forceEntityConstructor: false,
|
|
69
|
+
forceUndefined: false,
|
|
70
|
+
processOnCreateHooksEarly: false,
|
|
71
|
+
ensureDatabase: true,
|
|
72
|
+
ensureIndexes: false,
|
|
73
|
+
batchSize: 300,
|
|
74
|
+
hashAlgorithm: 'md5',
|
|
75
|
+
debug: false,
|
|
76
|
+
ignoreDeprecations: false,
|
|
77
|
+
verbose: false,
|
|
78
|
+
driverOptions: {},
|
|
79
|
+
migrations: {
|
|
80
|
+
tableName: 'mikro_orm_migrations',
|
|
81
|
+
path: './migrations',
|
|
82
|
+
glob: '!(*.d).{js,ts,cjs}',
|
|
83
|
+
silent: false,
|
|
84
|
+
transactional: true,
|
|
85
|
+
disableForeignKeys: false,
|
|
86
|
+
allOrNothing: true,
|
|
87
|
+
dropTables: true,
|
|
88
|
+
safe: false,
|
|
89
|
+
snapshot: true,
|
|
90
|
+
emit: 'ts',
|
|
91
|
+
fileName: (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`,
|
|
92
|
+
},
|
|
93
|
+
schemaGenerator: {
|
|
94
|
+
disableForeignKeys: false,
|
|
95
|
+
createForeignKeyConstraints: true,
|
|
96
|
+
ignoreSchema: [],
|
|
97
|
+
skipTables: [],
|
|
98
|
+
skipColumns: {},
|
|
99
|
+
},
|
|
100
|
+
embeddables: {
|
|
101
|
+
prefixMode: 'relative',
|
|
102
|
+
},
|
|
103
|
+
entityGenerator: {
|
|
104
|
+
forceUndefined: true,
|
|
105
|
+
undefinedDefaults: false,
|
|
106
|
+
scalarTypeInDecorator: false,
|
|
107
|
+
bidirectionalRelations: true,
|
|
108
|
+
identifiedReferences: true,
|
|
109
|
+
scalarPropertiesForRelations: 'never',
|
|
110
|
+
entityDefinition: 'defineEntity',
|
|
111
|
+
enumMode: 'dictionary',
|
|
112
|
+
fileName: (className) => className,
|
|
113
|
+
onlyPurePivotTables: false,
|
|
114
|
+
outputPurePivotTables: false,
|
|
115
|
+
readOnlyPivotTables: false,
|
|
116
|
+
useCoreBaseEntity: false,
|
|
117
|
+
},
|
|
118
|
+
metadataCache: {
|
|
119
|
+
pretty: false,
|
|
120
|
+
adapter: FileCacheAdapter,
|
|
121
|
+
options: { cacheDir: process.cwd() + '/temp' },
|
|
122
|
+
},
|
|
123
|
+
resultCache: {
|
|
124
|
+
adapter: MemoryCacheAdapter,
|
|
125
|
+
expiration: 1000, // 1s
|
|
126
|
+
options: {},
|
|
127
|
+
},
|
|
128
|
+
metadataProvider: ReflectMetadataProvider,
|
|
129
|
+
highlighter: new NullHighlighter(),
|
|
130
|
+
seeder: {
|
|
131
|
+
path: './seeders',
|
|
132
|
+
defaultSeeder: 'DatabaseSeeder',
|
|
133
|
+
glob: '!(*.d).{js,ts}',
|
|
134
|
+
emit: 'ts',
|
|
135
|
+
fileName: (className) => className,
|
|
136
|
+
},
|
|
137
|
+
preferReadReplicas: true,
|
|
138
|
+
dynamicImportProvider: /* v8 ignore next */ (id) => import(id),
|
|
139
|
+
};
|
|
14
140
|
export class Configuration {
|
|
15
|
-
static DEFAULTS = {
|
|
16
|
-
pool: {},
|
|
17
|
-
entities: [],
|
|
18
|
-
entitiesTs: [],
|
|
19
|
-
extensions: [],
|
|
20
|
-
subscribers: [],
|
|
21
|
-
filters: {},
|
|
22
|
-
discovery: {
|
|
23
|
-
warnWhenNoEntities: true,
|
|
24
|
-
requireEntitiesArray: false,
|
|
25
|
-
checkDuplicateTableNames: true,
|
|
26
|
-
checkDuplicateFieldNames: true,
|
|
27
|
-
checkDuplicateEntities: true,
|
|
28
|
-
checkNonPersistentCompositeProps: true,
|
|
29
|
-
alwaysAnalyseProperties: true,
|
|
30
|
-
disableDynamicFileAccess: false,
|
|
31
|
-
inferDefaultValues: true,
|
|
32
|
-
},
|
|
33
|
-
strict: false,
|
|
34
|
-
validate: false,
|
|
35
|
-
validateRequired: true,
|
|
36
|
-
context: (name) => RequestContext.getEntityManager(name),
|
|
37
|
-
contextName: 'default',
|
|
38
|
-
allowGlobalContext: false,
|
|
39
|
-
// eslint-disable-next-line no-console
|
|
40
|
-
logger: console.log.bind(console),
|
|
41
|
-
colors: true,
|
|
42
|
-
findOneOrFailHandler: (entityName, where) => NotFoundError.findOneFailed(entityName, where),
|
|
43
|
-
findExactlyOneOrFailHandler: (entityName, where) => NotFoundError.findExactlyOneFailed(entityName, where),
|
|
44
|
-
baseDir: process.cwd(),
|
|
45
|
-
hydrator: ObjectHydrator,
|
|
46
|
-
flushMode: FlushMode.AUTO,
|
|
47
|
-
loadStrategy: LoadStrategy.BALANCED,
|
|
48
|
-
dataloader: DataloaderType.NONE,
|
|
49
|
-
populateWhere: PopulateHint.ALL,
|
|
50
|
-
ignoreUndefinedInQuery: false,
|
|
51
|
-
onQuery: sql => sql,
|
|
52
|
-
autoJoinOneToOneOwner: true,
|
|
53
|
-
autoJoinRefsForFilters: true,
|
|
54
|
-
filtersOnRelations: true,
|
|
55
|
-
propagationOnPrototype: true,
|
|
56
|
-
populateAfterFlush: true,
|
|
57
|
-
serialization: {
|
|
58
|
-
includePrimaryKeys: true,
|
|
59
|
-
},
|
|
60
|
-
assign: {
|
|
61
|
-
updateNestedEntities: true,
|
|
62
|
-
updateByPrimaryKey: true,
|
|
63
|
-
mergeObjectProperties: false,
|
|
64
|
-
mergeEmbeddedProperties: true,
|
|
65
|
-
ignoreUndefined: false,
|
|
66
|
-
},
|
|
67
|
-
persistOnCreate: true,
|
|
68
|
-
upsertManaged: true,
|
|
69
|
-
forceEntityConstructor: false,
|
|
70
|
-
forceUndefined: false,
|
|
71
|
-
processOnCreateHooksEarly: false,
|
|
72
|
-
ensureDatabase: true,
|
|
73
|
-
ensureIndexes: false,
|
|
74
|
-
batchSize: 300,
|
|
75
|
-
hashAlgorithm: 'md5',
|
|
76
|
-
debug: false,
|
|
77
|
-
ignoreDeprecations: false,
|
|
78
|
-
verbose: false,
|
|
79
|
-
driverOptions: {},
|
|
80
|
-
migrations: {
|
|
81
|
-
tableName: 'mikro_orm_migrations',
|
|
82
|
-
path: './migrations',
|
|
83
|
-
glob: '!(*.d).{js,ts,cjs}',
|
|
84
|
-
silent: false,
|
|
85
|
-
transactional: true,
|
|
86
|
-
disableForeignKeys: false,
|
|
87
|
-
allOrNothing: true,
|
|
88
|
-
dropTables: true,
|
|
89
|
-
safe: false,
|
|
90
|
-
snapshot: true,
|
|
91
|
-
emit: 'ts',
|
|
92
|
-
fileName: (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`,
|
|
93
|
-
},
|
|
94
|
-
schemaGenerator: {
|
|
95
|
-
disableForeignKeys: false,
|
|
96
|
-
createForeignKeyConstraints: true,
|
|
97
|
-
ignoreSchema: [],
|
|
98
|
-
skipTables: [],
|
|
99
|
-
skipColumns: {},
|
|
100
|
-
},
|
|
101
|
-
embeddables: {
|
|
102
|
-
prefixMode: 'relative',
|
|
103
|
-
},
|
|
104
|
-
entityGenerator: {
|
|
105
|
-
forceUndefined: true,
|
|
106
|
-
undefinedDefaults: false,
|
|
107
|
-
scalarTypeInDecorator: false,
|
|
108
|
-
bidirectionalRelations: true,
|
|
109
|
-
identifiedReferences: true,
|
|
110
|
-
scalarPropertiesForRelations: 'never',
|
|
111
|
-
entityDefinition: 'defineEntity',
|
|
112
|
-
enumMode: 'dictionary',
|
|
113
|
-
fileName: (className) => className,
|
|
114
|
-
onlyPurePivotTables: false,
|
|
115
|
-
outputPurePivotTables: false,
|
|
116
|
-
readOnlyPivotTables: false,
|
|
117
|
-
useCoreBaseEntity: false,
|
|
118
|
-
},
|
|
119
|
-
metadataCache: {
|
|
120
|
-
pretty: false,
|
|
121
|
-
adapter: FileCacheAdapter,
|
|
122
|
-
options: { cacheDir: process.cwd() + '/temp' },
|
|
123
|
-
},
|
|
124
|
-
resultCache: {
|
|
125
|
-
adapter: MemoryCacheAdapter,
|
|
126
|
-
expiration: 1000, // 1s
|
|
127
|
-
options: {},
|
|
128
|
-
},
|
|
129
|
-
metadataProvider: ReflectMetadataProvider,
|
|
130
|
-
highlighter: new NullHighlighter(),
|
|
131
|
-
seeder: {
|
|
132
|
-
path: './seeders',
|
|
133
|
-
defaultSeeder: 'DatabaseSeeder',
|
|
134
|
-
glob: '!(*.d).{js,ts}',
|
|
135
|
-
emit: 'ts',
|
|
136
|
-
fileName: (className) => className,
|
|
137
|
-
},
|
|
138
|
-
preferReadReplicas: true,
|
|
139
|
-
dynamicImportProvider: /* v8 ignore next */ (id) => import(id),
|
|
140
|
-
};
|
|
141
141
|
options;
|
|
142
142
|
logger;
|
|
143
143
|
driver;
|
|
@@ -148,7 +148,7 @@ export class Configuration {
|
|
|
148
148
|
if (options.dynamicImportProvider) {
|
|
149
149
|
Utils.setDynamicImportProvider(options.dynamicImportProvider);
|
|
150
150
|
}
|
|
151
|
-
this.options = Utils.mergeConfig({},
|
|
151
|
+
this.options = Utils.mergeConfig({}, DEFAULTS, options);
|
|
152
152
|
this.options.baseDir = Utils.absolutePath(this.options.baseDir);
|
|
153
153
|
if (validate) {
|
|
154
154
|
this.validateOptions();
|
|
@@ -195,7 +195,7 @@ export class Configuration {
|
|
|
195
195
|
* Resets the configuration to its default value
|
|
196
196
|
*/
|
|
197
197
|
reset(key) {
|
|
198
|
-
this.options[key] =
|
|
198
|
+
this.options[key] = DEFAULTS[key];
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* Gets Logger instance.
|
|
@@ -307,9 +307,7 @@ export class Configuration {
|
|
|
307
307
|
if (!this.options.clientUrl) {
|
|
308
308
|
this.options.clientUrl = this.platform.getDefaultClientUrl();
|
|
309
309
|
}
|
|
310
|
-
|
|
311
|
-
this.options.implicitTransactions = this.platform.usesImplicitTransactions();
|
|
312
|
-
}
|
|
310
|
+
this.options.implicitTransactions ??= this.platform.usesImplicitTransactions();
|
|
313
311
|
try {
|
|
314
312
|
const url = new URL(this.options.clientUrl);
|
|
315
313
|
if (url.pathname) {
|
|
@@ -325,12 +323,8 @@ export class Configuration {
|
|
|
325
323
|
if (validate && !this.options.dbName && this.options.clientUrl) {
|
|
326
324
|
throw new Error("No database specified, `clientUrl` option provided but it's missing the pathname.");
|
|
327
325
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
if (!this.options.charset) {
|
|
332
|
-
this.options.charset = this.platform.getDefaultCharset();
|
|
333
|
-
}
|
|
326
|
+
this.options.schema ??= this.platform.getDefaultSchemaName();
|
|
327
|
+
this.options.charset ??= this.platform.getDefaultCharset();
|
|
334
328
|
Object.keys(this.options.filters).forEach(key => {
|
|
335
329
|
this.options.filters[key].default ??= true;
|
|
336
330
|
});
|
|
@@ -13,7 +13,7 @@ export declare class ConfigurationLoader {
|
|
|
13
13
|
* @param paths Array of possible paths for a configuration file. Files will be checked in order, and the first existing one will be used. Defaults to the output of {@link ConfigurationLoader.getConfigPaths}.
|
|
14
14
|
* @param options Additional options to augment the final configuration with.
|
|
15
15
|
*/
|
|
16
|
-
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager
|
|
16
|
+
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>>(contextName?: string, paths?: string[], options?: Partial<Options>): Promise<Configuration<D, EM>>;
|
|
17
17
|
static getConfigFile(paths: string[]): Promise<[string, unknown] | []>;
|
|
18
18
|
static getPackageConfig(basePath?: string): Dictionary;
|
|
19
19
|
static getSettings(): Settings;
|
package/utils/Utils.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export declare class Utils {
|
|
|
134
134
|
static getCompositeKeyHash<T>(data: EntityData<T>, meta: EntityMetadata<T>, convertCustomTypes?: boolean, platform?: Platform, flat?: boolean): string;
|
|
135
135
|
static getPrimaryKeyHash(pks: (string | Buffer | Date)[]): string;
|
|
136
136
|
static splitPrimaryKeys<T extends object>(key: string): EntityKey<T>[];
|
|
137
|
-
static getPrimaryKeyValues<T>(entity: T,
|
|
137
|
+
static getPrimaryKeyValues<T>(entity: T, meta: EntityMetadata<T>, allowScalar?: boolean, convertCustomTypes?: boolean): any;
|
|
138
138
|
static getPrimaryKeyCond<T>(entity: T, primaryKeys: EntityKey<T>[]): Record<string, Primary<T>> | null;
|
|
139
139
|
/**
|
|
140
140
|
* Maps nested FKs from `[1, 2, 3]` to `[1, [2, 3]]`.
|
package/utils/Utils.js
CHANGED
|
@@ -6,7 +6,7 @@ import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
7
|
import { tokenize } from 'esprima';
|
|
8
8
|
import { clone } from './clone.js';
|
|
9
|
-
import { ARRAY_OPERATORS,
|
|
9
|
+
import { ARRAY_OPERATORS, GroupOperator, JSON_KEY_OPERATORS, PlainObject, QueryOperator, ReferenceKind, } from '../enums.js';
|
|
10
10
|
import { helper } from '../entity/wrap.js';
|
|
11
11
|
export const ObjectBindingPattern = Symbol('ObjectBindingPattern');
|
|
12
12
|
function compareConstructors(a, b) {
|
|
@@ -486,8 +486,7 @@ export class Utils {
|
|
|
486
486
|
static splitPrimaryKeys(key) {
|
|
487
487
|
return key.split(this.PK_SEPARATOR);
|
|
488
488
|
}
|
|
489
|
-
|
|
490
|
-
static getPrimaryKeyValues(entity, primaryKeys, allowScalar = false, convertCustomTypes = false) {
|
|
489
|
+
static getPrimaryKeyValues(entity, meta, allowScalar = false, convertCustomTypes = false) {
|
|
491
490
|
/* v8 ignore next 3 */
|
|
492
491
|
if (entity == null) {
|
|
493
492
|
return entity;
|
|
@@ -498,15 +497,13 @@ export class Utils {
|
|
|
498
497
|
}
|
|
499
498
|
return val;
|
|
500
499
|
}
|
|
501
|
-
const meta = Array.isArray(primaryKeys) ? undefined : primaryKeys;
|
|
502
|
-
primaryKeys = Array.isArray(primaryKeys) ? primaryKeys : meta.primaryKeys;
|
|
503
500
|
let pk;
|
|
504
501
|
if (Utils.isEntity(entity, true)) {
|
|
505
502
|
pk = helper(entity).getPrimaryKey(convertCustomTypes);
|
|
506
503
|
}
|
|
507
504
|
else {
|
|
508
|
-
pk = primaryKeys.reduce((o, pk) => {
|
|
509
|
-
const targetMeta = meta
|
|
505
|
+
pk = meta.primaryKeys.reduce((o, pk) => {
|
|
506
|
+
const targetMeta = meta.properties[pk].targetMeta;
|
|
510
507
|
if (targetMeta && Utils.isPlainObject(entity[pk])) {
|
|
511
508
|
o[pk] = Utils.getPrimaryKeyValues(entity[pk], targetMeta, allowScalar, convertCustomTypes);
|
|
512
509
|
}
|
|
@@ -516,12 +513,12 @@ export class Utils {
|
|
|
516
513
|
return o;
|
|
517
514
|
}, {});
|
|
518
515
|
}
|
|
519
|
-
if (primaryKeys.length > 1) {
|
|
516
|
+
if (meta.primaryKeys.length > 1) {
|
|
520
517
|
return toArray(pk);
|
|
521
518
|
}
|
|
522
519
|
if (allowScalar) {
|
|
523
520
|
if (Utils.isPlainObject(pk)) {
|
|
524
|
-
return pk[primaryKeys[0]];
|
|
521
|
+
return pk[(meta.primaryKeys)[0]];
|
|
525
522
|
}
|
|
526
523
|
return pk;
|
|
527
524
|
}
|