@mikro-orm/core 7.0.0-dev.0 → 7.0.0-dev.2
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 +18 -13
- package/EntityManager.js +202 -202
- package/MikroORM.d.ts +7 -6
- package/MikroORM.js +33 -45
- package/cache/CacheAdapter.js +1 -2
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +18 -26
- package/cache/GeneratedCacheAdapter.d.ts +2 -2
- package/cache/GeneratedCacheAdapter.js +1 -5
- package/cache/MemoryCacheAdapter.d.ts +1 -1
- package/cache/MemoryCacheAdapter.js +1 -5
- package/cache/NullCacheAdapter.d.ts +1 -1
- package/cache/NullCacheAdapter.js +1 -5
- package/cache/index.d.ts +5 -5
- package/cache/index.js +5 -21
- package/connections/Connection.d.ts +7 -7
- package/connections/Connection.js +8 -12
- package/connections/index.d.ts +1 -1
- package/connections/index.js +1 -17
- package/decorators/Check.d.ts +1 -1
- package/decorators/Check.js +5 -8
- package/decorators/CreateRequestContext.d.ts +1 -1
- package/decorators/CreateRequestContext.js +9 -13
- package/decorators/Embeddable.d.ts +1 -1
- package/decorators/Embeddable.js +3 -6
- package/decorators/Embedded.d.ts +1 -1
- package/decorators/Embedded.js +10 -12
- package/decorators/Entity.d.ts +2 -2
- package/decorators/Entity.js +5 -8
- package/decorators/Enum.d.ts +2 -2
- package/decorators/Enum.js +7 -10
- package/decorators/Filter.d.ts +1 -1
- package/decorators/Filter.js +3 -6
- package/decorators/Formula.d.ts +2 -2
- package/decorators/Formula.js +7 -10
- package/decorators/Indexed.d.ts +2 -2
- package/decorators/Indexed.js +6 -10
- package/decorators/ManyToMany.d.ts +3 -3
- package/decorators/ManyToMany.js +10 -12
- package/decorators/ManyToOne.d.ts +3 -3
- package/decorators/ManyToOne.js +10 -12
- package/decorators/OneToMany.d.ts +3 -3
- package/decorators/OneToMany.js +11 -14
- package/decorators/OneToOne.d.ts +4 -4
- package/decorators/OneToOne.js +4 -7
- package/decorators/PrimaryKey.d.ts +2 -2
- package/decorators/PrimaryKey.js +10 -13
- package/decorators/Property.d.ts +5 -5
- package/decorators/Property.js +10 -12
- package/decorators/Transactional.d.ts +2 -2
- package/decorators/Transactional.js +7 -10
- package/decorators/hooks.js +23 -35
- package/decorators/index.d.ts +17 -17
- package/decorators/index.js +17 -36
- package/drivers/DatabaseDriver.d.ts +13 -12
- package/drivers/DatabaseDriver.js +60 -64
- package/drivers/IDatabaseDriver.d.ts +12 -12
- package/drivers/IDatabaseDriver.js +1 -4
- package/drivers/index.d.ts +2 -2
- package/drivers/index.js +2 -18
- package/entity/ArrayCollection.d.ts +2 -2
- package/entity/ArrayCollection.js +29 -33
- package/entity/BaseEntity.d.ts +6 -6
- package/entity/BaseEntity.js +17 -21
- package/entity/Collection.d.ts +6 -6
- package/entity/Collection.js +40 -44
- package/entity/EntityAssigner.d.ts +2 -2
- package/entity/EntityAssigner.js +58 -63
- package/entity/EntityFactory.d.ts +3 -3
- package/entity/EntityFactory.js +58 -62
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +41 -45
- package/entity/EntityIdentifier.d.ts +1 -1
- package/entity/EntityIdentifier.js +1 -5
- package/entity/EntityLoader.d.ts +5 -5
- package/entity/EntityLoader.js +92 -96
- package/entity/EntityRepository.d.ts +7 -7
- package/entity/EntityRepository.js +7 -11
- package/entity/EntityValidator.d.ts +1 -1
- package/entity/EntityValidator.js +25 -29
- package/entity/Reference.d.ts +2 -2
- package/entity/Reference.js +35 -42
- package/entity/WrappedEntity.d.ts +12 -12
- package/entity/WrappedEntity.js +23 -27
- package/entity/index.d.ts +13 -13
- package/entity/index.js +13 -29
- package/entity/utils.d.ts +1 -1
- package/entity/utils.js +9 -12
- package/entity/wrap.d.ts +1 -1
- package/entity/wrap.js +2 -6
- package/enums.d.ts +3 -3
- package/enums.js +37 -41
- package/errors.d.ts +1 -1
- package/errors.js +15 -24
- package/events/EventManager.d.ts +3 -3
- package/events/EventManager.js +8 -12
- package/events/EventSubscriber.d.ts +5 -4
- package/events/EventSubscriber.js +1 -2
- package/events/TransactionEventBroadcaster.d.ts +3 -3
- package/events/TransactionEventBroadcaster.js +1 -5
- package/events/index.d.ts +3 -3
- package/events/index.js +3 -19
- package/exceptions.js +18 -39
- package/hydration/Hydrator.d.ts +5 -5
- package/hydration/Hydrator.js +3 -6
- package/hydration/ObjectHydrator.d.ts +3 -3
- package/hydration/ObjectHydrator.js +25 -28
- package/hydration/index.d.ts +2 -2
- package/hydration/index.js +2 -18
- package/index.d.ts +21 -21
- package/index.js +21 -46
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +9 -13
- package/logging/Logger.d.ts +1 -1
- package/logging/Logger.js +1 -2
- package/logging/SimpleLogger.d.ts +2 -2
- package/logging/SimpleLogger.js +2 -6
- package/logging/colors.js +1 -5
- package/logging/index.d.ts +4 -4
- package/logging/index.js +4 -20
- package/metadata/EntitySchema.d.ts +12 -4
- package/metadata/EntitySchema.js +41 -45
- package/metadata/MetadataDiscovery.d.ts +7 -7
- package/metadata/MetadataDiscovery.js +174 -177
- package/metadata/MetadataProvider.d.ts +2 -2
- package/metadata/MetadataProvider.js +4 -7
- package/metadata/MetadataStorage.d.ts +2 -2
- package/metadata/MetadataStorage.js +15 -19
- package/metadata/MetadataValidator.d.ts +4 -4
- package/metadata/MetadataValidator.js +49 -53
- package/metadata/ReflectMetadataProvider.d.ts +2 -2
- package/metadata/ReflectMetadataProvider.js +8 -12
- package/metadata/index.d.ts +6 -6
- package/metadata/index.js +6 -22
- package/naming-strategy/AbstractNamingStrategy.d.ts +2 -2
- package/naming-strategy/AbstractNamingStrategy.js +4 -8
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +1 -1
- package/naming-strategy/EntityCaseNamingStrategy.js +2 -6
- package/naming-strategy/MongoNamingStrategy.d.ts +1 -1
- package/naming-strategy/MongoNamingStrategy.js +2 -6
- package/naming-strategy/NamingStrategy.d.ts +1 -1
- package/naming-strategy/NamingStrategy.js +1 -2
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -1
- package/naming-strategy/UnderscoreNamingStrategy.js +2 -6
- package/naming-strategy/index.d.ts +5 -5
- package/naming-strategy/index.js +5 -21
- package/package.json +5 -14
- package/platforms/ExceptionConverter.d.ts +2 -2
- package/platforms/ExceptionConverter.js +4 -8
- package/platforms/Platform.d.ts +10 -10
- package/platforms/Platform.js +57 -61
- package/platforms/index.d.ts +2 -2
- package/platforms/index.js +2 -18
- package/serialization/EntitySerializer.d.ts +2 -2
- package/serialization/EntitySerializer.js +36 -41
- package/serialization/EntityTransformer.d.ts +1 -1
- package/serialization/EntityTransformer.js +27 -31
- package/serialization/SerializationContext.d.ts +2 -2
- package/serialization/SerializationContext.js +10 -14
- package/serialization/index.d.ts +3 -3
- package/serialization/index.js +3 -19
- package/types/ArrayType.d.ts +3 -3
- package/types/ArrayType.js +7 -11
- package/types/BigIntType.d.ts +3 -3
- package/types/BigIntType.js +3 -6
- package/types/BlobType.d.ts +3 -3
- package/types/BlobType.js +2 -8
- package/types/BooleanType.d.ts +3 -3
- package/types/BooleanType.js +2 -6
- package/types/CharacterType.d.ts +3 -3
- package/types/CharacterType.js +2 -6
- package/types/DateTimeType.d.ts +3 -3
- package/types/DateTimeType.js +2 -6
- package/types/DateType.d.ts +3 -3
- package/types/DateType.js +2 -6
- package/types/DecimalType.d.ts +3 -3
- package/types/DecimalType.js +4 -7
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +3 -6
- package/types/EnumArrayType.d.ts +4 -4
- package/types/EnumArrayType.js +5 -10
- package/types/EnumType.d.ts +3 -3
- package/types/EnumType.js +2 -6
- package/types/FloatType.d.ts +3 -3
- package/types/FloatType.js +2 -6
- package/types/IntegerType.d.ts +3 -3
- package/types/IntegerType.js +2 -6
- package/types/IntervalType.d.ts +3 -3
- package/types/IntervalType.js +2 -6
- package/types/JsonType.d.ts +3 -3
- package/types/JsonType.js +2 -6
- package/types/MediumIntType.d.ts +3 -3
- package/types/MediumIntType.js +2 -6
- package/types/SmallIntType.d.ts +3 -3
- package/types/SmallIntType.js +2 -6
- package/types/StringType.d.ts +3 -3
- package/types/StringType.js +2 -6
- package/types/TextType.d.ts +3 -3
- package/types/TextType.js +2 -6
- package/types/TimeType.d.ts +3 -3
- package/types/TimeType.js +4 -8
- package/types/TinyIntType.d.ts +3 -3
- package/types/TinyIntType.js +3 -6
- package/types/Type.d.ts +2 -2
- package/types/Type.js +5 -9
- package/types/Uint8ArrayType.d.ts +3 -3
- package/types/Uint8ArrayType.js +3 -9
- package/types/UnknownType.d.ts +3 -3
- package/types/UnknownType.js +2 -6
- package/types/UuidType.d.ts +3 -3
- package/types/UuidType.js +2 -6
- package/types/index.d.ts +25 -25
- package/types/index.js +52 -79
- package/typings.d.ts +22 -20
- package/typings.js +34 -38
- package/unit-of-work/ChangeSet.d.ts +1 -1
- package/unit-of-work/ChangeSet.js +13 -17
- package/unit-of-work/ChangeSetComputer.d.ts +8 -7
- package/unit-of-work/ChangeSetComputer.js +26 -30
- package/unit-of-work/ChangeSetPersister.d.ts +7 -6
- package/unit-of-work/ChangeSetPersister.js +44 -47
- package/unit-of-work/CommitOrderCalculator.d.ts +1 -1
- package/unit-of-work/CommitOrderCalculator.js +6 -10
- package/unit-of-work/IdentityMap.d.ts +1 -1
- package/unit-of-work/IdentityMap.js +1 -5
- package/unit-of-work/UnitOfWork.d.ts +8 -7
- package/unit-of-work/UnitOfWork.js +171 -172
- package/unit-of-work/index.d.ts +6 -6
- package/unit-of-work/index.js +6 -22
- package/utils/AbstractSchemaGenerator.d.ts +6 -6
- package/utils/AbstractSchemaGenerator.js +7 -11
- package/utils/Configuration.d.ts +26 -27
- package/utils/Configuration.js +50 -55
- package/utils/ConfigurationLoader.d.ts +9 -8
- package/utils/ConfigurationLoader.js +71 -86
- package/utils/Cursor.d.ts +3 -3
- package/utils/Cursor.js +22 -25
- package/utils/DataloaderUtils.d.ts +4 -4
- package/utils/DataloaderUtils.js +12 -16
- package/utils/EntityComparator.d.ts +2 -2
- package/utils/EntityComparator.js +48 -52
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +1 -5
- package/utils/QueryHelper.d.ts +3 -3
- package/utils/QueryHelper.js +47 -51
- package/utils/RawQueryFragment.d.ts +1 -1
- package/utils/RawQueryFragment.js +16 -24
- package/utils/RequestContext.d.ts +2 -2
- package/utils/RequestContext.js +3 -7
- package/utils/TransactionContext.d.ts +1 -1
- package/utils/TransactionContext.js +4 -8
- package/utils/Utils.d.ts +16 -12
- package/utils/Utils.js +89 -93
- package/utils/clone.js +8 -11
- package/utils/index.d.ts +13 -13
- package/utils/index.js +13 -29
- package/utils/resolveContextProvider.d.ts +3 -3
- package/utils/resolveContextProvider.js +9 -12
- package/utils/upsert-utils.d.ts +3 -3
- package/utils/upsert-utils.js +5 -9
- package/index.mjs +0 -199
package/metadata/EntitySchema.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
|
-
const EnumArrayType_1 = require("../types/EnumArrayType");
|
|
10
|
-
class EntitySchema {
|
|
1
|
+
import { EntityMetadata, } from '../typings.js';
|
|
2
|
+
import { BaseEntity } from '../entity/BaseEntity.js';
|
|
3
|
+
import { Cascade, ReferenceKind } from '../enums.js';
|
|
4
|
+
import { Type } from '../types/Type.js';
|
|
5
|
+
import { Utils } from '../utils/Utils.js';
|
|
6
|
+
import { EnumArrayType } from '../types/EnumArrayType.js';
|
|
7
|
+
export class EntitySchema {
|
|
11
8
|
/**
|
|
12
9
|
* When schema links the entity class via `class` option, this registry allows the lookup from opposite side,
|
|
13
10
|
* so we can use the class in `entities` option just like the EntitySchema instance.
|
|
14
11
|
*/
|
|
15
12
|
static REGISTRY = new Map();
|
|
16
|
-
_meta = new
|
|
13
|
+
_meta = new EntityMetadata();
|
|
17
14
|
internal = false;
|
|
18
15
|
initialized = false;
|
|
19
16
|
constructor(meta) {
|
|
@@ -25,7 +22,7 @@ class EntitySchema {
|
|
|
25
22
|
EntitySchema.REGISTRY.set(meta.class, this);
|
|
26
23
|
}
|
|
27
24
|
if (meta.tableName || meta.collection) {
|
|
28
|
-
|
|
25
|
+
Utils.renameKey(meta, 'tableName', 'collection');
|
|
29
26
|
meta.tableName = meta.collection;
|
|
30
27
|
}
|
|
31
28
|
Object.assign(this._meta, { className: meta.name }, meta);
|
|
@@ -46,7 +43,7 @@ class EntitySchema {
|
|
|
46
43
|
}
|
|
47
44
|
};
|
|
48
45
|
if (name !== options.name) {
|
|
49
|
-
|
|
46
|
+
Utils.renameKey(options, 'name', 'fieldName');
|
|
50
47
|
}
|
|
51
48
|
rename(options, 'fieldName', 'fieldNames');
|
|
52
49
|
rename(options, 'ref', 'ref');
|
|
@@ -54,11 +51,11 @@ class EntitySchema {
|
|
|
54
51
|
rename(options, 'inverseJoinColumn', 'inverseJoinColumns');
|
|
55
52
|
rename(options, 'referenceColumnName', 'referencedColumnNames');
|
|
56
53
|
rename(options, 'columnType', 'columnTypes');
|
|
57
|
-
const prop = { name, kind:
|
|
58
|
-
if (type &&
|
|
54
|
+
const prop = { name, kind: ReferenceKind.SCALAR, ...options, type: this.normalizeType(options, type) };
|
|
55
|
+
if (type && Type.isMappedType(type.prototype)) {
|
|
59
56
|
prop.type = type;
|
|
60
57
|
}
|
|
61
|
-
if (
|
|
58
|
+
if (Utils.isString(prop.formula)) {
|
|
62
59
|
const formula = prop.formula; // tmp var is needed here
|
|
63
60
|
prop.formula = () => formula;
|
|
64
61
|
}
|
|
@@ -69,11 +66,11 @@ class EntitySchema {
|
|
|
69
66
|
}
|
|
70
67
|
addEnum(name, type, options = {}) {
|
|
71
68
|
if (options.items instanceof Function) {
|
|
72
|
-
options.items =
|
|
69
|
+
options.items = Utils.extractEnumValues(options.items());
|
|
73
70
|
}
|
|
74
71
|
// enum arrays are simple numeric/string arrays, the constraint is enforced in the custom type only
|
|
75
72
|
if (options.array && !options.type) {
|
|
76
|
-
options.type = new
|
|
73
|
+
options.type = new EnumArrayType(`${this._meta.className}.${name}`, options.items);
|
|
77
74
|
options.enum = false;
|
|
78
75
|
}
|
|
79
76
|
const prop = { enum: true, ...options };
|
|
@@ -97,19 +94,19 @@ class EntitySchema {
|
|
|
97
94
|
this.addProperty(name, type, options);
|
|
98
95
|
}
|
|
99
96
|
addEmbedded(name, options) {
|
|
100
|
-
|
|
97
|
+
Utils.defaultValue(options, 'prefix', true);
|
|
101
98
|
if (options.array) {
|
|
102
99
|
options.object = true; // force object mode for arrays
|
|
103
100
|
}
|
|
104
101
|
this._meta.properties[name] = {
|
|
105
102
|
name,
|
|
106
103
|
type: this.normalizeType(options),
|
|
107
|
-
kind:
|
|
104
|
+
kind: ReferenceKind.EMBEDDED,
|
|
108
105
|
...options,
|
|
109
106
|
};
|
|
110
107
|
}
|
|
111
108
|
addManyToOne(name, type, options) {
|
|
112
|
-
const prop = this.createProperty(
|
|
109
|
+
const prop = this.createProperty(ReferenceKind.MANY_TO_ONE, options);
|
|
113
110
|
prop.owner = true;
|
|
114
111
|
if (prop.joinColumns && !prop.fieldNames) {
|
|
115
112
|
prop.fieldNames = prop.joinColumns;
|
|
@@ -125,21 +122,21 @@ class EntitySchema {
|
|
|
125
122
|
options.owner = true;
|
|
126
123
|
}
|
|
127
124
|
if (options.owner) {
|
|
128
|
-
|
|
125
|
+
Utils.renameKey(options, 'mappedBy', 'inversedBy');
|
|
129
126
|
}
|
|
130
|
-
const prop = this.createProperty(
|
|
127
|
+
const prop = this.createProperty(ReferenceKind.MANY_TO_MANY, options);
|
|
131
128
|
this.addProperty(name, type, prop);
|
|
132
129
|
}
|
|
133
130
|
addOneToMany(name, type, options) {
|
|
134
|
-
const prop = this.createProperty(
|
|
131
|
+
const prop = this.createProperty(ReferenceKind.ONE_TO_MANY, options);
|
|
135
132
|
this.addProperty(name, type, prop);
|
|
136
133
|
}
|
|
137
134
|
addOneToOne(name, type, options) {
|
|
138
|
-
const prop = this.createProperty(
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
const prop = this.createProperty(ReferenceKind.ONE_TO_ONE, options);
|
|
136
|
+
Utils.defaultValue(prop, 'owner', !!prop.inversedBy || !prop.mappedBy);
|
|
137
|
+
Utils.defaultValue(prop, 'unique', prop.owner);
|
|
141
138
|
if (prop.owner && options.mappedBy) {
|
|
142
|
-
|
|
139
|
+
Utils.renameKey(prop, 'mappedBy', 'inversedBy');
|
|
143
140
|
}
|
|
144
141
|
if (prop.joinColumns && !prop.fieldNames) {
|
|
145
142
|
prop.fieldNames = prop.joinColumns;
|
|
@@ -167,14 +164,14 @@ class EntitySchema {
|
|
|
167
164
|
this._meta.prototype = proto.prototype;
|
|
168
165
|
this._meta.className = proto.name;
|
|
169
166
|
if (!sameClass || !this._meta.constructorParams) {
|
|
170
|
-
const tokens =
|
|
171
|
-
this._meta.constructorParams =
|
|
172
|
-
this._meta.toJsonParams =
|
|
167
|
+
const tokens = Utils.tokenize(proto);
|
|
168
|
+
this._meta.constructorParams = Utils.getParamNames(tokens, 'constructor');
|
|
169
|
+
this._meta.toJsonParams = Utils.getParamNames(tokens, 'toJSON').filter(p => p !== '...args');
|
|
173
170
|
}
|
|
174
171
|
if (!this.internal) {
|
|
175
172
|
EntitySchema.REGISTRY.set(proto, this);
|
|
176
173
|
}
|
|
177
|
-
if (Object.getPrototypeOf(proto) !==
|
|
174
|
+
if (Object.getPrototypeOf(proto) !== BaseEntity) {
|
|
178
175
|
this._meta.extends = this._meta.extends || Object.getPrototypeOf(proto).name || undefined;
|
|
179
176
|
}
|
|
180
177
|
}
|
|
@@ -208,29 +205,29 @@ class EntitySchema {
|
|
|
208
205
|
this.initProperties();
|
|
209
206
|
this.initPrimaryKeys();
|
|
210
207
|
this._meta.props = Object.values(this._meta.properties);
|
|
211
|
-
this._meta.relations = this._meta.props.filter(prop => typeof prop.kind !== 'undefined' && prop.kind !==
|
|
208
|
+
this._meta.relations = this._meta.props.filter(prop => typeof prop.kind !== 'undefined' && prop.kind !== ReferenceKind.SCALAR && prop.kind !== ReferenceKind.EMBEDDED);
|
|
212
209
|
this.initialized = true;
|
|
213
210
|
return this;
|
|
214
211
|
}
|
|
215
212
|
initProperties() {
|
|
216
|
-
|
|
217
|
-
if (
|
|
213
|
+
Utils.entries(this._meta.properties).forEach(([name, options]) => {
|
|
214
|
+
if (Type.isMappedType(options.type)) {
|
|
218
215
|
options.type ??= options.type.constructor.name;
|
|
219
216
|
}
|
|
220
217
|
switch (options.kind) {
|
|
221
|
-
case
|
|
218
|
+
case ReferenceKind.ONE_TO_ONE:
|
|
222
219
|
this.addOneToOne(name, options.type, options);
|
|
223
220
|
break;
|
|
224
|
-
case
|
|
221
|
+
case ReferenceKind.ONE_TO_MANY:
|
|
225
222
|
this.addOneToMany(name, options.type, options);
|
|
226
223
|
break;
|
|
227
|
-
case
|
|
224
|
+
case ReferenceKind.MANY_TO_ONE:
|
|
228
225
|
this.addManyToOne(name, options.type, options);
|
|
229
226
|
break;
|
|
230
|
-
case
|
|
227
|
+
case ReferenceKind.MANY_TO_MANY:
|
|
231
228
|
this.addManyToMany(name, options.type, options);
|
|
232
229
|
break;
|
|
233
|
-
case
|
|
230
|
+
case ReferenceKind.EMBEDDED:
|
|
234
231
|
this.addEmbedded(name, options);
|
|
235
232
|
break;
|
|
236
233
|
default:
|
|
@@ -257,7 +254,7 @@ class EntitySchema {
|
|
|
257
254
|
if (pks.length > 0) {
|
|
258
255
|
this._meta.primaryKeys = pks.map(prop => prop.name);
|
|
259
256
|
this._meta.compositePK = pks.length > 1;
|
|
260
|
-
this._meta.simplePK = !this._meta.compositePK && pks[0].kind ===
|
|
257
|
+
this._meta.simplePK = !this._meta.compositePK && pks[0].kind === ReferenceKind.SCALAR && !pks[0].customType;
|
|
261
258
|
}
|
|
262
259
|
if (pks.length === 1 && ['number', 'bigint'].includes(pks[0].type)) {
|
|
263
260
|
pks[0].autoincrement ??= true;
|
|
@@ -269,12 +266,12 @@ class EntitySchema {
|
|
|
269
266
|
}
|
|
270
267
|
normalizeType(options, type) {
|
|
271
268
|
if ('entity' in options) {
|
|
272
|
-
if (
|
|
269
|
+
if (Utils.isString(options.entity)) {
|
|
273
270
|
type = options.type = options.entity;
|
|
274
271
|
}
|
|
275
272
|
else if (options.entity) {
|
|
276
273
|
const tmp = options.entity();
|
|
277
|
-
type = options.type = Array.isArray(tmp) ? tmp.map(t =>
|
|
274
|
+
type = options.type = Array.isArray(tmp) ? tmp.map(t => Utils.className(t)).sort().join(' | ') : Utils.className(tmp);
|
|
278
275
|
}
|
|
279
276
|
}
|
|
280
277
|
if (type instanceof Function) {
|
|
@@ -288,9 +285,8 @@ class EntitySchema {
|
|
|
288
285
|
createProperty(kind, options) {
|
|
289
286
|
return {
|
|
290
287
|
kind,
|
|
291
|
-
cascade: [
|
|
288
|
+
cascade: [Cascade.PERSIST],
|
|
292
289
|
...options,
|
|
293
290
|
};
|
|
294
291
|
}
|
|
295
292
|
}
|
|
296
|
-
exports.EntitySchema = EntitySchema;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type Constructor, EntityMetadata } from '../typings';
|
|
2
|
-
import type { Configuration } from '../utils/Configuration';
|
|
3
|
-
import { MetadataStorage } from './MetadataStorage';
|
|
4
|
-
import { EntitySchema } from './EntitySchema';
|
|
5
|
-
import type { Platform } from '../platforms';
|
|
1
|
+
import { type Constructor, EntityMetadata } from '../typings.js';
|
|
2
|
+
import type { Configuration } from '../utils/Configuration.js';
|
|
3
|
+
import { MetadataStorage } from './MetadataStorage.js';
|
|
4
|
+
import { EntitySchema } from './EntitySchema.js';
|
|
5
|
+
import type { Platform } from '../platforms/Platform.js';
|
|
6
6
|
export declare class MetadataDiscovery {
|
|
7
7
|
private readonly metadata;
|
|
8
8
|
private readonly platform;
|
|
@@ -15,8 +15,8 @@ export declare class MetadataDiscovery {
|
|
|
15
15
|
private readonly validator;
|
|
16
16
|
private readonly discovered;
|
|
17
17
|
constructor(metadata: MetadataStorage, platform: Platform, config: Configuration);
|
|
18
|
-
discover(
|
|
19
|
-
discoverSync(
|
|
18
|
+
discover(preferTs?: boolean): Promise<MetadataStorage>;
|
|
19
|
+
discoverSync(preferTs?: boolean): MetadataStorage;
|
|
20
20
|
private mapDiscoveredEntities;
|
|
21
21
|
processDiscoveredEntities(discovered: EntityMetadata[]): EntityMetadata[];
|
|
22
22
|
private findEntities;
|