@mikro-orm/core 6.6.3-dev.1 → 6.6.3-dev.10
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.js +3 -9
- package/entity/defineEntity.d.ts +26 -7
- package/package.json +2 -2
- package/utils/EntityComparator.js +4 -0
package/MikroORM.js
CHANGED
|
@@ -153,15 +153,9 @@ class MikroORM {
|
|
|
153
153
|
* Closes the database connection.
|
|
154
154
|
*/
|
|
155
155
|
async close(force = false) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (this.config.getMetadataCacheAdapter()?.close) {
|
|
160
|
-
await this.config.getMetadataCacheAdapter().close();
|
|
161
|
-
}
|
|
162
|
-
if (this.config.getResultCacheAdapter()?.close) {
|
|
163
|
-
await this.config.getResultCacheAdapter().close();
|
|
164
|
-
}
|
|
156
|
+
await this.driver.close(force);
|
|
157
|
+
await this.config.getMetadataCacheAdapter()?.close?.();
|
|
158
|
+
await this.config.getResultCacheAdapter()?.close?.();
|
|
165
159
|
}
|
|
166
160
|
/**
|
|
167
161
|
* Gets the `MetadataStorage` (without parameters) or `EntityMetadata` instance when provided with the `entityName` parameter.
|
package/entity/defineEntity.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { ManyToOneOptions } from '../decorators/ManyToOne';
|
|
|
6
6
|
import type { OneToManyOptions } from '../decorators/OneToMany';
|
|
7
7
|
import type { OneToOneOptions } from '../decorators/OneToOne';
|
|
8
8
|
import type { ManyToManyOptions } from '../decorators/ManyToMany';
|
|
9
|
-
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, Ref } from '../typings';
|
|
9
|
+
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, Ref, IndexCallback } from '../typings';
|
|
10
10
|
import type { ScalarReference } from './Reference';
|
|
11
11
|
import type { SerializeOptions } from '../serialization/EntitySerializer';
|
|
12
12
|
import type { Cascade, DeferMode, EventType, LoadStrategy, QueryOrderMap } from '../enums';
|
|
@@ -416,13 +416,32 @@ declare const propertyBuilders: {
|
|
|
416
416
|
interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
417
417
|
unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
|
|
418
418
|
};
|
|
419
|
-
export
|
|
419
|
+
export interface EntityMetadataWithProperties<TProperties extends Record<string, any>, TPK extends (keyof TProperties)[] | undefined = undefined, TBase = never> extends Omit<Partial<EntityMetadata<InferEntityFromProperties<TProperties, TPK>>>, 'properties' | 'extends' | 'primaryKeys' | 'hooks' | 'discriminatorColumn' | 'versionProperty' | 'concurrencyCheckKeys' | 'serializedPrimaryKey' | 'indexes' | 'uniques'> {
|
|
420
420
|
name: string;
|
|
421
|
-
extends?: EntityName<
|
|
422
|
-
properties:
|
|
423
|
-
primaryKeys?:
|
|
424
|
-
hooks?: DefineEntityHooks<InferEntityFromProperties<
|
|
425
|
-
|
|
421
|
+
extends?: EntityName<TBase>;
|
|
422
|
+
properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
|
|
423
|
+
primaryKeys?: TPK & InferPrimaryKey<TProperties>[];
|
|
424
|
+
hooks?: DefineEntityHooks<InferEntityFromProperties<TProperties, TPK>>;
|
|
425
|
+
discriminatorColumn?: keyof TProperties;
|
|
426
|
+
versionProperty?: keyof TProperties;
|
|
427
|
+
concurrencyCheckKeys?: Set<keyof TProperties>;
|
|
428
|
+
serializedPrimaryKey?: keyof TProperties;
|
|
429
|
+
indexes?: {
|
|
430
|
+
properties?: keyof TProperties | (keyof TProperties)[];
|
|
431
|
+
name?: string;
|
|
432
|
+
type?: string;
|
|
433
|
+
options?: Dictionary;
|
|
434
|
+
expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK>>;
|
|
435
|
+
}[];
|
|
436
|
+
uniques?: {
|
|
437
|
+
properties?: keyof TProperties | (keyof TProperties)[];
|
|
438
|
+
name?: string;
|
|
439
|
+
options?: Dictionary;
|
|
440
|
+
expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK>>;
|
|
441
|
+
deferMode?: DeferMode | `${DeferMode}`;
|
|
442
|
+
}[];
|
|
443
|
+
}
|
|
444
|
+
export declare function defineEntity<TProperties extends Record<string, any>, const TPK extends (keyof TProperties)[] | undefined = undefined, TBase = never>(meta: EntityMetadataWithProperties<TProperties, TPK, TBase>): EntitySchema<InferEntityFromProperties<TProperties, TPK>, TBase>;
|
|
426
445
|
export declare function defineEntity<Entity = any, Base = never>(meta: Omit<Partial<EntityMetadata<Entity>>, 'properties' | 'extends'> & {
|
|
427
446
|
class: EntityClass<Entity>;
|
|
428
447
|
extends?: EntityName<Base>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.6.3-dev.
|
|
3
|
+
"version": "6.6.3-dev.10",
|
|
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.3.2",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.6.3-dev.
|
|
67
|
+
"mikro-orm": "6.6.3-dev.10",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -6,6 +6,7 @@ const enums_1 = require("../enums");
|
|
|
6
6
|
const Utils_1 = require("./Utils");
|
|
7
7
|
const JsonType_1 = require("../types/JsonType");
|
|
8
8
|
const RawQueryFragment_1 = require("./RawQueryFragment");
|
|
9
|
+
const EntityIdentifier_1 = require("../entity/EntityIdentifier");
|
|
9
10
|
class EntityComparator {
|
|
10
11
|
metadata;
|
|
11
12
|
platform;
|
|
@@ -522,8 +523,11 @@ class EntityComparator {
|
|
|
522
523
|
return val;
|
|
523
524
|
};
|
|
524
525
|
context.set('toArray', toArray);
|
|
526
|
+
context.set('EntityIdentifier', EntityIdentifier_1.EntityIdentifier);
|
|
525
527
|
ret += ` if (entity${entityKey} === null) {\n`;
|
|
526
528
|
ret += ` ret${dataKey} = null;\n`;
|
|
529
|
+
ret += ` } else if (entity${entityKey}?.__helper.__identifier && !entity${entityKey}.__helper.hasPrimaryKey()) {\n`;
|
|
530
|
+
ret += ` ret${dataKey} = entity${entityKey}?.__helper.__identifier;\n`;
|
|
527
531
|
ret += ` } else if (typeof entity${entityKey} !== 'undefined') {\n`;
|
|
528
532
|
ret += ` ret${dataKey} = toArray(entity${entityKey}.__helper.getPrimaryKey(true));\n`;
|
|
529
533
|
ret += ` }\n`;
|