@mikro-orm/core 7.0.0-dev.23 → 7.0.0-dev.231
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 +91 -59
- package/EntityManager.js +303 -251
- package/MikroORM.d.ts +44 -35
- package/MikroORM.js +109 -143
- package/README.md +2 -0
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +17 -8
- package/cache/GeneratedCacheAdapter.d.ts +0 -1
- package/cache/GeneratedCacheAdapter.js +0 -2
- package/cache/index.d.ts +0 -1
- package/cache/index.js +0 -1
- package/connections/Connection.d.ts +12 -5
- package/connections/Connection.js +21 -12
- package/drivers/DatabaseDriver.d.ts +25 -16
- package/drivers/DatabaseDriver.js +118 -35
- package/drivers/IDatabaseDriver.d.ts +42 -19
- package/entity/BaseEntity.d.ts +61 -2
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +101 -29
- package/entity/Collection.js +436 -104
- package/entity/EntityAssigner.d.ts +1 -1
- package/entity/EntityAssigner.js +26 -18
- package/entity/EntityFactory.d.ts +7 -1
- package/entity/EntityFactory.js +83 -54
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +48 -15
- package/entity/EntityLoader.d.ts +7 -6
- package/entity/EntityLoader.js +221 -93
- package/entity/EntityRepository.d.ts +27 -7
- package/entity/EntityRepository.js +8 -2
- package/entity/PolymorphicRef.d.ts +12 -0
- package/entity/PolymorphicRef.js +18 -0
- package/entity/Reference.d.ts +1 -5
- package/entity/Reference.js +21 -12
- package/entity/WrappedEntity.d.ts +0 -5
- package/entity/WrappedEntity.js +2 -7
- package/entity/defineEntity.d.ts +380 -310
- package/entity/defineEntity.js +124 -273
- package/entity/index.d.ts +2 -2
- package/entity/index.js +2 -2
- package/entity/utils.js +1 -1
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +65 -0
- package/enums.d.ts +8 -6
- package/enums.js +2 -1
- package/errors.d.ts +20 -10
- package/errors.js +55 -23
- package/events/EventManager.d.ts +2 -1
- package/events/EventManager.js +19 -11
- package/hydration/Hydrator.js +1 -2
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +87 -35
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +1 -0
- package/logging/SimpleLogger.d.ts +1 -1
- package/logging/colors.d.ts +1 -1
- package/logging/colors.js +7 -6
- package/logging/index.d.ts +1 -0
- package/logging/index.js +1 -0
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +11 -0
- package/metadata/EntitySchema.d.ts +47 -23
- package/metadata/EntitySchema.js +92 -33
- package/metadata/MetadataDiscovery.d.ts +64 -9
- package/metadata/MetadataDiscovery.js +778 -325
- package/metadata/MetadataProvider.d.ts +11 -2
- package/metadata/MetadataProvider.js +46 -2
- package/metadata/MetadataStorage.d.ts +13 -11
- package/metadata/MetadataStorage.js +70 -37
- package/metadata/MetadataValidator.d.ts +32 -9
- package/metadata/MetadataValidator.js +196 -41
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +1 -1
- package/metadata/index.js +1 -1
- package/metadata/types.d.ts +526 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
- package/naming-strategy/AbstractNamingStrategy.js +20 -2
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
- package/naming-strategy/EntityCaseNamingStrategy.js +6 -5
- package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
- package/naming-strategy/MongoNamingStrategy.js +6 -6
- package/naming-strategy/NamingStrategy.d.ts +28 -4
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
- package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
- package/not-supported.d.ts +2 -0
- package/not-supported.js +4 -0
- package/package.json +19 -11
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +7 -14
- package/platforms/Platform.js +20 -43
- package/serialization/EntitySerializer.d.ts +5 -0
- package/serialization/EntitySerializer.js +47 -27
- package/serialization/EntityTransformer.js +28 -18
- package/serialization/SerializationContext.d.ts +6 -6
- package/serialization/SerializationContext.js +3 -3
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +2 -3
- package/types/BigIntType.d.ts +8 -6
- package/types/BigIntType.js +1 -1
- package/types/BlobType.d.ts +0 -1
- package/types/BlobType.js +0 -3
- package/types/BooleanType.d.ts +1 -0
- package/types/BooleanType.js +3 -0
- package/types/DecimalType.d.ts +6 -4
- package/types/DecimalType.js +2 -2
- package/types/DoubleType.js +1 -1
- package/types/EnumArrayType.js +1 -2
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/TinyIntType.js +1 -1
- package/types/Type.d.ts +2 -4
- package/types/Type.js +3 -3
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/Uint8ArrayType.js +1 -4
- package/types/index.d.ts +1 -1
- package/typings.d.ts +381 -171
- package/typings.js +97 -44
- package/unit-of-work/ChangeSet.d.ts +4 -6
- package/unit-of-work/ChangeSet.js +4 -5
- package/unit-of-work/ChangeSetComputer.d.ts +1 -3
- package/unit-of-work/ChangeSetComputer.js +35 -14
- package/unit-of-work/ChangeSetPersister.d.ts +7 -3
- package/unit-of-work/ChangeSetPersister.js +83 -25
- package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
- package/unit-of-work/CommitOrderCalculator.js +13 -13
- package/unit-of-work/IdentityMap.d.ts +12 -0
- package/unit-of-work/IdentityMap.js +39 -1
- package/unit-of-work/UnitOfWork.d.ts +27 -3
- package/unit-of-work/UnitOfWork.js +258 -92
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +28 -17
- package/utils/AsyncContext.d.ts +6 -0
- package/utils/AsyncContext.js +42 -0
- package/utils/Configuration.d.ts +795 -209
- package/utils/Configuration.js +150 -192
- package/utils/ConfigurationLoader.d.ts +1 -54
- package/utils/ConfigurationLoader.js +1 -352
- package/utils/Cursor.d.ts +0 -3
- package/utils/Cursor.js +24 -11
- package/utils/DataloaderUtils.d.ts +10 -5
- package/utils/DataloaderUtils.js +29 -12
- package/utils/EntityComparator.d.ts +16 -9
- package/utils/EntityComparator.js +158 -58
- package/utils/QueryHelper.d.ts +18 -6
- package/utils/QueryHelper.js +76 -23
- package/utils/RawQueryFragment.d.ts +28 -34
- package/utils/RawQueryFragment.js +35 -71
- package/utils/RequestContext.js +2 -2
- package/utils/TransactionContext.js +2 -2
- package/utils/TransactionManager.js +28 -4
- package/utils/Utils.d.ts +14 -127
- package/utils/Utils.js +85 -397
- package/utils/clone.js +8 -23
- package/utils/env-vars.d.ts +7 -0
- package/utils/env-vars.js +97 -0
- package/utils/fs-utils.d.ts +33 -0
- package/utils/fs-utils.js +192 -0
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -1
- package/utils/upsert-utils.d.ts +9 -4
- package/utils/upsert-utils.js +46 -3
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -13
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -32
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -11
- package/decorators/Embedded.d.ts +0 -12
- package/decorators/Embedded.js +0 -18
- package/decorators/Entity.d.ts +0 -33
- package/decorators/Entity.js +0 -12
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -16
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -8
- package/decorators/Formula.d.ts +0 -4
- package/decorators/Formula.js +0 -15
- package/decorators/Indexed.d.ts +0 -19
- package/decorators/Indexed.js +0 -20
- package/decorators/ManyToMany.d.ts +0 -42
- package/decorators/ManyToMany.js +0 -14
- package/decorators/ManyToOne.d.ts +0 -34
- package/decorators/ManyToOne.js +0 -14
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -17
- package/decorators/OneToOne.d.ts +0 -28
- package/decorators/OneToOne.js +0 -7
- package/decorators/PrimaryKey.d.ts +0 -8
- package/decorators/PrimaryKey.js +0 -20
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -32
- package/decorators/Transactional.d.ts +0 -14
- package/decorators/Transactional.js +0 -28
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -47
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -17
- package/entity/ArrayCollection.d.ts +0 -118
- package/entity/ArrayCollection.js +0 -407
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -150
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -44
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -28
package/entity/defineEntity.d.ts
CHANGED
|
@@ -1,177 +1,224 @@
|
|
|
1
1
|
import type { EntityManager } from '../EntityManager.js';
|
|
2
|
-
import type { ColumnType, PropertyOptions, ReferenceOptions } from '../
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type { OneToManyOptions } from '../decorators/OneToMany.js';
|
|
7
|
-
import type { OneToOneOptions } from '../decorators/OneToOne.js';
|
|
8
|
-
import type { ManyToManyOptions } from '../decorators/ManyToMany.js';
|
|
9
|
-
import type { AnyString, GeneratedColumnCallback, Constructor, Opt, Hidden, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata } from '../typings.js';
|
|
10
|
-
import type { Reference, ScalarReference } from './Reference.js';
|
|
2
|
+
import type { ColumnType, PropertyOptions, ReferenceOptions, EnumOptions, EmbeddedOptions, ManyToOneOptions, OneToManyOptions, OneToOneOptions, ManyToManyOptions } from '../metadata/types.js';
|
|
3
|
+
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, EntityRepositoryType, Hidden, Opt, Primary, EntityClass, EntitySchemaWithMeta, InferEntity, MaybeReturnType, Ref, IndexCallback, FormulaCallback, EntityCtor, IsNever } from '../typings.js';
|
|
4
|
+
import type { Raw } from '../utils/RawQueryFragment.js';
|
|
5
|
+
import type { ScalarReference } from './Reference.js';
|
|
11
6
|
import type { SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
12
|
-
import type { Cascade, DeferMode, LoadStrategy, QueryOrderMap } from '../enums.js';
|
|
13
|
-
import type {
|
|
7
|
+
import type { Cascade, DeferMode, EmbeddedPrefixMode, LoadStrategy, QueryOrderKeysFlat, QueryOrderMap } from '../enums.js';
|
|
8
|
+
import type { EventSubscriber } from '../events/EventSubscriber.js';
|
|
14
9
|
import type { IType, Type } from '../types/Type.js';
|
|
15
10
|
import { types } from '../types/index.js';
|
|
16
|
-
import {
|
|
11
|
+
import type { Collection } from './Collection.js';
|
|
12
|
+
import type { FilterOptions } from '../drivers/IDatabaseDriver.js';
|
|
13
|
+
export type UniversalPropertyKeys = keyof PropertyOptions<any> | keyof EnumOptions<any> | keyof EmbeddedOptions<any, any> | keyof ReferenceOptions<any, any> | keyof ManyToOneOptions<any, any> | keyof OneToManyOptions<any, any> | keyof OneToOneOptions<any, any> | keyof ManyToManyOptions<any, any>;
|
|
14
|
+
type BuilderExtraKeys = '~options' | '~type' | '$type';
|
|
15
|
+
type ExcludeKeys = 'entity' | 'items';
|
|
16
|
+
type BuilderKeys = Exclude<UniversalPropertyKeys, ExcludeKeys> | BuilderExtraKeys;
|
|
17
|
+
type IncludeKeysForProperty = Exclude<keyof PropertyOptions<any>, ExcludeKeys> | BuilderExtraKeys;
|
|
18
|
+
type IncludeKeysForEnumOptions = Exclude<keyof EnumOptions<any>, ExcludeKeys> | BuilderExtraKeys;
|
|
19
|
+
type IncludeKeysForEmbeddedOptions = Exclude<keyof EmbeddedOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
20
|
+
type IncludeKeysForManyToOneOptions = Exclude<keyof ManyToOneOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
21
|
+
type IncludeKeysForOneToManyOptions = Exclude<keyof OneToManyOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
22
|
+
type IncludeKeysForOneToOneOptions = Exclude<keyof OneToOneOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
23
|
+
type IncludeKeysForManyToManyOptions = Exclude<keyof ManyToManyOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
17
24
|
/** @internal */
|
|
18
|
-
export declare class
|
|
19
|
-
'~options':
|
|
25
|
+
export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys extends BuilderKeys> implements Record<Exclude<UniversalPropertyKeys, ExcludeKeys>, any> {
|
|
26
|
+
'~options': Options;
|
|
20
27
|
'~type'?: {
|
|
21
28
|
value: Value;
|
|
22
29
|
};
|
|
23
|
-
constructor(options:
|
|
30
|
+
constructor(options: any);
|
|
31
|
+
protected assignOptions(options: EmptyOptions): any;
|
|
32
|
+
/**
|
|
33
|
+
* Set the TypeScript type of the property.
|
|
34
|
+
*/
|
|
35
|
+
$type<T>(): UniversalPropertyOptionsBuilder<T, Options, IncludeKeys>;
|
|
36
|
+
/**
|
|
37
|
+
* Set the TypeScript type for custom types that map to objects.
|
|
38
|
+
* This method provides type safety for custom types by specifying the runtime type,
|
|
39
|
+
* raw database value type, and optional serialized type.
|
|
40
|
+
*
|
|
41
|
+
* @template Runtime - The runtime type that the property will have in JavaScript
|
|
42
|
+
* @template Raw - The raw value type as stored in the database
|
|
43
|
+
* @template Serialized - The type when serialized (defaults to Raw)
|
|
44
|
+
* @returns PropertyOptionsBuilder with IType wrapper for type safety
|
|
45
|
+
*/
|
|
46
|
+
$type<Runtime, Raw, Serialized = Raw>(): UniversalPropertyOptionsBuilder<IType<Runtime, Raw, Serialized>, Options, IncludeKeys>;
|
|
24
47
|
/**
|
|
25
48
|
* Alias for `fieldName`.
|
|
26
49
|
*/
|
|
27
|
-
name(name:
|
|
50
|
+
name<T extends string>(name: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'fieldName'> & {
|
|
51
|
+
fieldName: T;
|
|
52
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
28
53
|
/**
|
|
29
54
|
* Specify database column name for this property.
|
|
30
55
|
*
|
|
31
56
|
* @see https://mikro-orm.io/docs/naming-strategy
|
|
32
57
|
*/
|
|
33
|
-
fieldName(fieldName:
|
|
58
|
+
fieldName<T extends string>(fieldName: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'fieldName'> & {
|
|
59
|
+
fieldName: T;
|
|
60
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
34
61
|
/**
|
|
35
62
|
* Specify database column names for this property.
|
|
36
63
|
* Same as `fieldName` but for composite FKs.
|
|
37
64
|
*
|
|
38
65
|
* @see https://mikro-orm.io/docs/naming-strategy
|
|
39
66
|
*/
|
|
40
|
-
fieldNames(...fieldNames: string[]):
|
|
67
|
+
fieldNames(...fieldNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
41
68
|
/**
|
|
42
69
|
* Specify an exact database column type for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. This option is only for simple properties represented by a single column. (SQL only)
|
|
43
70
|
*/
|
|
44
|
-
columnType(columnType: ColumnType | AnyString):
|
|
71
|
+
columnType(columnType: ColumnType | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
45
72
|
/**
|
|
46
73
|
* Specify an exact database column type for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. This option is suitable for composite keys, where one property is represented by multiple columns. (SQL only)
|
|
47
74
|
*/
|
|
48
|
-
columnTypes(...columnTypes: (ColumnType | AnyString)[]):
|
|
75
|
+
columnTypes(...columnTypes: (ColumnType | AnyString)[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
49
76
|
/**
|
|
50
77
|
* Explicitly specify the runtime type.
|
|
51
78
|
*
|
|
52
79
|
* @see https://mikro-orm.io/docs/metadata-providers
|
|
53
80
|
* @see https://mikro-orm.io/docs/custom-types
|
|
54
81
|
*/
|
|
55
|
-
type<TType extends PropertyValueType>(type: TType):
|
|
82
|
+
type<TType extends PropertyValueType>(type: TType): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
56
83
|
/**
|
|
57
84
|
* Runtime type of the property. This is the JS type that your property is mapped to, e.g. `string` or `number`, and is normally inferred automatically via `reflect-metadata`.
|
|
58
85
|
* In some cases, the inference won't work, and you might need to specify the `runtimeType` explicitly - the most common one is when you use a union type with null like `foo: number | null`.
|
|
59
86
|
*/
|
|
60
|
-
runtimeType(runtimeType: string):
|
|
87
|
+
runtimeType(runtimeType: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
61
88
|
/**
|
|
62
89
|
* Set length of database column, used for datetime/timestamp/varchar column types for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
63
90
|
*/
|
|
64
|
-
length(length: number):
|
|
91
|
+
length(length: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
65
92
|
/**
|
|
66
93
|
* Set precision of database column to represent the number of significant digits. (SQL only)
|
|
67
94
|
*/
|
|
68
|
-
precision(precision: number):
|
|
95
|
+
precision(precision: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
69
96
|
/**
|
|
70
97
|
* Set scale of database column to represents the number of digits after the decimal point. (SQL only)
|
|
71
98
|
*/
|
|
72
|
-
scale(scale: number):
|
|
99
|
+
scale(scale: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
73
100
|
/**
|
|
74
101
|
* Explicitly specify the auto increment of the primary key.
|
|
75
102
|
*/
|
|
76
|
-
autoincrement(autoincrement?:
|
|
103
|
+
autoincrement<T extends boolean = true>(autoincrement?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'autoincrement'> & {
|
|
104
|
+
autoincrement: T;
|
|
105
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
77
106
|
/**
|
|
78
107
|
* Add the property to the `returning` statement.
|
|
79
108
|
*/
|
|
80
|
-
returning(returning?: boolean):
|
|
109
|
+
returning(returning?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
81
110
|
/**
|
|
82
111
|
* Automatically set the property value when entity gets created, executed during flush operation.
|
|
83
|
-
* @param entity
|
|
84
112
|
*/
|
|
85
|
-
onCreate(onCreate: (entity: any, em: EntityManager) => Value):
|
|
113
|
+
onCreate(onCreate: (entity: any, em: EntityManager) => Value): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
|
|
114
|
+
onCreate: (...args: any[]) => any;
|
|
115
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
86
116
|
/**
|
|
87
117
|
* Automatically update the property value every time entity gets updated, executed during flush operation.
|
|
88
|
-
* @param entity
|
|
89
118
|
*/
|
|
90
|
-
onUpdate(onUpdate: (entity: any, em: EntityManager) => Value):
|
|
119
|
+
onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
91
120
|
/**
|
|
92
121
|
* Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
|
|
93
122
|
* This is a runtime value, assignable to the entity property. (SQL only)
|
|
94
123
|
*/
|
|
95
|
-
default
|
|
124
|
+
default<T extends string | string[] | number | number[] | boolean | null | Date | Raw>(defaultValue: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'default'> & {
|
|
125
|
+
default: T;
|
|
126
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
96
127
|
/**
|
|
97
128
|
* Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
98
129
|
* Since v4 you should use defaultRaw for SQL functions. e.g. now()
|
|
99
130
|
*/
|
|
100
|
-
defaultRaw(defaultRaw: string):
|
|
131
|
+
defaultRaw(defaultRaw: string): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
|
|
132
|
+
defaultRaw: string;
|
|
133
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
134
|
+
/**
|
|
135
|
+
* Allow controlling `filters` option. This will be overridden with `em.fork` or `FindOptions` if provided.
|
|
136
|
+
*/
|
|
137
|
+
filters(filters: FilterOptions): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
101
138
|
/**
|
|
102
139
|
* Set to map some SQL snippet for the entity.
|
|
103
140
|
*
|
|
104
141
|
* @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
|
|
105
142
|
*/
|
|
106
|
-
formula
|
|
143
|
+
formula<T extends string | FormulaCallback<any>>(formula: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'formula'> & {
|
|
144
|
+
formula: T;
|
|
145
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
107
146
|
/**
|
|
108
147
|
* For generated columns. This will be appended to the column type after the `generated always` clause.
|
|
109
148
|
*/
|
|
110
|
-
generated(generated: string | GeneratedColumnCallback<any>):
|
|
149
|
+
generated(generated: string | GeneratedColumnCallback<any>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
111
150
|
/**
|
|
112
151
|
* Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
|
|
113
152
|
*/
|
|
114
|
-
nullable<T extends boolean = true>(nullable?: T):
|
|
153
|
+
nullable<T extends boolean = true>(nullable?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'nullable'> & {
|
|
154
|
+
nullable: T;
|
|
155
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
115
156
|
/**
|
|
116
157
|
* Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
117
158
|
*/
|
|
118
|
-
unsigned(unsigned?: boolean):
|
|
159
|
+
unsigned(unsigned?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
119
160
|
/**
|
|
120
161
|
* Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
|
|
121
162
|
*/
|
|
122
|
-
persist(persist?:
|
|
163
|
+
persist<T extends boolean = true>(persist?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'persist'> & {
|
|
164
|
+
persist: T;
|
|
165
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
123
166
|
/**
|
|
124
167
|
* Set false to disable hydration of this property. Useful for persisted getters.
|
|
125
168
|
*/
|
|
126
|
-
hydrate(hydrate?: boolean):
|
|
169
|
+
hydrate(hydrate?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
127
170
|
/**
|
|
128
171
|
* Enable `ScalarReference` wrapper for lazy values. Use this in combination with `lazy: true` to have a type-safe accessor object in place of the value.
|
|
129
172
|
*/
|
|
130
|
-
ref<T extends boolean = true>(ref?: T):
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
* @see https://mikro-orm.io/docs/unit-of-work#change-tracking-and-performance-considerations
|
|
135
|
-
*/
|
|
136
|
-
trackChanges(trackChanges?: boolean): PropertyOptionsBuilder<Value>;
|
|
173
|
+
ref<T extends boolean = true>(ref?: T): UniversalPropertyOptionsBuilder<Value, Omit<Options, 'ref'> & {
|
|
174
|
+
ref: T;
|
|
175
|
+
}, IncludeKeys>;
|
|
137
176
|
/**
|
|
138
177
|
* Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
|
|
139
178
|
*/
|
|
140
|
-
hidden<T extends boolean = true>(hidden?: T):
|
|
179
|
+
hidden<T extends boolean = true>(hidden?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'hidden'> & {
|
|
180
|
+
hidden: T;
|
|
181
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
141
182
|
/**
|
|
142
183
|
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
|
|
143
184
|
*/
|
|
144
|
-
version(version?:
|
|
185
|
+
version<T extends boolean = true>(version?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'version'> & {
|
|
186
|
+
version: T;
|
|
187
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
145
188
|
/**
|
|
146
189
|
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
|
|
147
190
|
*/
|
|
148
|
-
concurrencyCheck(concurrencyCheck?: boolean):
|
|
191
|
+
concurrencyCheck(concurrencyCheck?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
149
192
|
/**
|
|
150
193
|
* Explicitly specify index on a property.
|
|
151
194
|
*/
|
|
152
|
-
index(index?: boolean | string):
|
|
195
|
+
index(index?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
153
196
|
/**
|
|
154
197
|
* Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
155
198
|
*/
|
|
156
|
-
unique(unique?: boolean | string):
|
|
199
|
+
unique(unique?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
157
200
|
/**
|
|
158
201
|
* Specify column with check constraints. (Postgres driver only)
|
|
159
202
|
*
|
|
160
203
|
* @see https://mikro-orm.io/docs/defining-entities#check-constraints
|
|
161
204
|
*/
|
|
162
|
-
check(check: string | CheckCallback<any>):
|
|
205
|
+
check(check: string | CheckCallback<any>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
163
206
|
/**
|
|
164
207
|
* Set to omit the property from the select clause for lazy loading.
|
|
165
208
|
*
|
|
166
209
|
* @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
|
|
167
210
|
*/
|
|
168
|
-
lazy<T extends boolean = true>(lazy?: boolean, ref?: T):
|
|
211
|
+
lazy<T extends boolean = true>(lazy?: boolean, ref?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'ref'> & {
|
|
212
|
+
ref: T;
|
|
213
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
169
214
|
/**
|
|
170
215
|
* Set true to define entity's unique primary key identifier.
|
|
171
216
|
*
|
|
172
217
|
* @see https://mikro-orm.io/docs/decorators#primarykey
|
|
173
218
|
*/
|
|
174
|
-
primary(primary?:
|
|
219
|
+
primary<T extends boolean = true>(primary?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'primary'> & {
|
|
220
|
+
primary: T;
|
|
221
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
175
222
|
/**
|
|
176
223
|
* Set true to define the properties as setter. (virtual)
|
|
177
224
|
*
|
|
@@ -183,7 +230,7 @@ export declare class PropertyOptionsBuilder<Value> {
|
|
|
183
230
|
* }
|
|
184
231
|
* ```
|
|
185
232
|
*/
|
|
186
|
-
setter(setter?: boolean):
|
|
233
|
+
setter(setter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
187
234
|
/**
|
|
188
235
|
* Set true to define the properties as getter. (virtual)
|
|
189
236
|
*
|
|
@@ -195,7 +242,7 @@ export declare class PropertyOptionsBuilder<Value> {
|
|
|
195
242
|
* }
|
|
196
243
|
* ```
|
|
197
244
|
*/
|
|
198
|
-
getter(getter?: boolean):
|
|
245
|
+
getter(getter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
199
246
|
/**
|
|
200
247
|
* When defining a property over a method (not a getter, a regular function), you can use this option to point
|
|
201
248
|
* to the method name.
|
|
@@ -208,330 +255,353 @@ export declare class PropertyOptionsBuilder<Value> {
|
|
|
208
255
|
* }
|
|
209
256
|
* ```
|
|
210
257
|
*/
|
|
211
|
-
getterName(getterName: string):
|
|
258
|
+
getterName(getterName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
212
259
|
/**
|
|
213
260
|
* Set to define serialized primary key for MongoDB. (virtual)
|
|
214
261
|
* Alias for `@SerializedPrimaryKey()` decorator.
|
|
215
262
|
*
|
|
216
263
|
* @see https://mikro-orm.io/docs/decorators#serializedprimarykey
|
|
217
264
|
*/
|
|
218
|
-
serializedPrimaryKey(serializedPrimaryKey?: boolean):
|
|
265
|
+
serializedPrimaryKey(serializedPrimaryKey?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
219
266
|
/**
|
|
220
267
|
* Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
|
|
221
268
|
*
|
|
222
269
|
* @see https://mikro-orm.io/docs/serializing#property-serializers
|
|
223
270
|
*/
|
|
224
|
-
serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any):
|
|
271
|
+
serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
225
272
|
/**
|
|
226
273
|
* Specify name of key for the serialized value.
|
|
227
274
|
*/
|
|
228
|
-
serializedName(serializedName: string):
|
|
275
|
+
serializedName(serializedName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
229
276
|
/**
|
|
230
277
|
* Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
|
|
231
278
|
* otherwise only properties with a matching group are included.
|
|
232
279
|
*/
|
|
233
|
-
groups(...groups: string[]):
|
|
280
|
+
groups(...groups: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
234
281
|
/**
|
|
235
282
|
* Specify a custom order based on the values. (SQL only)
|
|
236
283
|
*/
|
|
237
|
-
customOrder(...customOrder: (string[] | number[] | boolean[])):
|
|
284
|
+
customOrder(...customOrder: (string[] | number[] | boolean[])): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
238
285
|
/**
|
|
239
286
|
* Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
240
287
|
*/
|
|
241
|
-
comment(comment: string):
|
|
288
|
+
comment(comment: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
242
289
|
/** mysql only */
|
|
243
|
-
extra(extra: string):
|
|
290
|
+
extra(extra: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
244
291
|
/**
|
|
245
292
|
* Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
|
|
246
293
|
*
|
|
247
294
|
* @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
|
|
248
295
|
*/
|
|
249
|
-
ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]):
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
$type<T>(): PropertyOptionsBuilder<T>;
|
|
254
|
-
/**
|
|
255
|
-
* Set the TypeScript type for custom types that map to objects.
|
|
256
|
-
* This method provides type safety for custom types by specifying the runtime type,
|
|
257
|
-
* raw database value type, and optional serialized type.
|
|
258
|
-
*
|
|
259
|
-
* @template Runtime - The runtime type that the property will have in JavaScript
|
|
260
|
-
* @template Raw - The raw value type as stored in the database
|
|
261
|
-
* @template Serialized - The type when serialized (defaults to Raw)
|
|
262
|
-
* @returns PropertyOptionsBuilder with IType wrapper for type safety
|
|
263
|
-
*/
|
|
264
|
-
$type<Runtime, Raw, Serialized = Raw>(): PropertyOptionsBuilder<IType<Runtime, Raw, Serialized>>;
|
|
265
|
-
}
|
|
266
|
-
/** @internal */
|
|
267
|
-
export declare class EnumOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
|
|
268
|
-
'~options': {
|
|
269
|
-
enum: true;
|
|
270
|
-
} & EnumOptions<any>;
|
|
271
|
-
constructor(options: EnumOptionsBuilder<Value>['~options']);
|
|
272
|
-
array<T extends boolean = true>(array?: T): EnumOptionsBuilder<T extends true ? Value[] : UnwrapArray<Value>>;
|
|
296
|
+
ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
297
|
+
array<T extends boolean = true>(array?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'array'> & {
|
|
298
|
+
array: T;
|
|
299
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
273
300
|
/** for postgres, by default it uses text column with check constraint */
|
|
274
|
-
nativeEnumName(nativeEnumName: string):
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
'~options': ({
|
|
279
|
-
kind: 'embedded';
|
|
280
|
-
entity: () => EntitySchema<any, any> | EntitySchema<any, any>[];
|
|
281
|
-
} & EmbeddedOptions<any, any> & PropertyOptions<any>);
|
|
282
|
-
constructor(options: EmbeddedOptionsBuilder<Value>['~options']);
|
|
283
|
-
prefix(prefix: string): EmbeddedOptionsBuilder<Value>;
|
|
284
|
-
prefixMode(prefixMode: EmbeddedPrefixMode): EmbeddedOptionsBuilder<Value>;
|
|
285
|
-
object(object?: boolean): EmbeddedOptionsBuilder<Value>;
|
|
286
|
-
array<T extends boolean = true>(array?: T): EmbeddedOptionsBuilder<T extends true ? Value[] : UnwrapArray<Value>>;
|
|
287
|
-
}
|
|
288
|
-
/** @internal */
|
|
289
|
-
export declare class ReferenceOptionsBuilder<Value extends object> extends PropertyOptionsBuilder<Value> {
|
|
290
|
-
'~options': ReferenceOptions<any, any>;
|
|
291
|
-
constructor(options: ReferenceOptionsBuilder<Value>['~options']);
|
|
301
|
+
nativeEnumName(nativeEnumName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
302
|
+
prefix(prefix: string | boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
303
|
+
prefixMode(prefixMode: EmbeddedPrefixMode): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
304
|
+
object(object?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
292
305
|
/** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
|
|
293
|
-
cascade(...cascade: Cascade[]):
|
|
306
|
+
cascade(...cascade: Cascade[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
294
307
|
/** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
|
|
295
|
-
eager(eager?: boolean):
|
|
308
|
+
eager(eager?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
296
309
|
/** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
|
|
297
|
-
strategy(strategy: LoadStrategy | `${LoadStrategy}`):
|
|
298
|
-
/**
|
|
299
|
-
* @internal
|
|
300
|
-
* re-declare to override type inference
|
|
301
|
-
*/
|
|
302
|
-
ref(ref?: boolean): ReferenceOptionsBuilder<any>;
|
|
303
|
-
/**
|
|
304
|
-
* @internal
|
|
305
|
-
* re-declare to override type inference
|
|
306
|
-
*/
|
|
307
|
-
primary(primary?: boolean): ReferenceOptionsBuilder<any>;
|
|
308
|
-
}
|
|
309
|
-
/** @internal */
|
|
310
|
-
export declare class ManyToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
|
|
311
|
-
'~options': ({
|
|
312
|
-
kind: 'm:n';
|
|
313
|
-
entity: () => EntitySchema<any, any>;
|
|
314
|
-
} & ManyToManyOptions<any, UnwrapCollection<TargetValue>>);
|
|
315
|
-
constructor(options: ManyToManyOptionsBuilder<TargetValue>['~options']);
|
|
310
|
+
strategy(strategy: LoadStrategy | `${LoadStrategy}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
316
311
|
/** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
|
|
317
|
-
owner(owner?:
|
|
312
|
+
owner<T extends boolean = true>(owner?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'owner'> & {
|
|
313
|
+
owner: T;
|
|
314
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
315
|
+
/** For polymorphic relations. Specifies the property name that stores the entity type discriminator. Defaults to the property name. */
|
|
316
|
+
discriminator(discriminator: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
317
|
+
/** For polymorphic relations. Custom mapping of discriminator values to entity class names. */
|
|
318
|
+
discriminatorMap(discriminatorMap: Dictionary<string>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
318
319
|
/** Point to the inverse side property name. */
|
|
319
|
-
inversedBy(inversedBy:
|
|
320
|
+
inversedBy(inversedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
320
321
|
/** Point to the owning side property name. */
|
|
321
|
-
mappedBy(mappedBy:
|
|
322
|
+
mappedBy(mappedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
322
323
|
/** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
|
|
323
|
-
where(...where: FilterQuery<object>[]):
|
|
324
|
+
where(...where: FilterQuery<object>[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
324
325
|
/** Set default ordering. */
|
|
325
|
-
orderBy(...orderBy: QueryOrderMap<object>[]):
|
|
326
|
+
orderBy(...orderBy: QueryOrderMap<object>[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
326
327
|
/** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
|
|
327
|
-
fixedOrder(fixedOrder?: boolean):
|
|
328
|
+
fixedOrder(fixedOrder?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
328
329
|
/** Override default order column name (`id`) for fixed ordering. */
|
|
329
|
-
fixedOrderColumn(fixedOrderColumn: string):
|
|
330
|
+
fixedOrderColumn(fixedOrderColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
330
331
|
/** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
|
|
331
|
-
pivotTable(pivotTable: string):
|
|
332
|
+
pivotTable(pivotTable: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
332
333
|
/** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
|
|
333
|
-
pivotEntity(pivotEntity:
|
|
334
|
+
pivotEntity(pivotEntity: () => EntityName): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
334
335
|
/** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
335
|
-
joinColumn(joinColumn: string):
|
|
336
|
+
joinColumn(joinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
336
337
|
/** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
337
|
-
joinColumns(...joinColumns: string[]):
|
|
338
|
+
joinColumns(...joinColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
338
339
|
/** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
339
|
-
inverseJoinColumn(inverseJoinColumn: string):
|
|
340
|
+
inverseJoinColumn(inverseJoinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
340
341
|
/** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
341
|
-
inverseJoinColumns(...inverseJoinColumns: string[]):
|
|
342
|
+
inverseJoinColumns(...inverseJoinColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
342
343
|
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
343
|
-
referenceColumnName(referenceColumnName: string):
|
|
344
|
+
referenceColumnName(referenceColumnName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
344
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. */
|
|
345
|
-
referencedColumnNames(...referencedColumnNames: string[]):
|
|
346
|
+
referencedColumnNames(...referencedColumnNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
347
|
+
/** Specify the property name on the target entity that this FK references instead of the primary key. */
|
|
348
|
+
targetKey(targetKey: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
346
349
|
/** What to do when the target entity gets deleted. */
|
|
347
|
-
deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString):
|
|
350
|
+
deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
348
351
|
/** What to do when the reference to the target entity gets updated. */
|
|
349
|
-
updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString):
|
|
350
|
-
}
|
|
351
|
-
/** @internal */
|
|
352
|
-
export declare class ManyToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
|
|
353
|
-
'~options': ({
|
|
354
|
-
kind: 'm:1';
|
|
355
|
-
entity: () => EntitySchema<any, any>;
|
|
356
|
-
} & ManyToOneOptions<any, UnwrapRef<TargetValue>>);
|
|
357
|
-
constructor(options: ManyToOneOptionsBuilder<TargetValue>['~options']);
|
|
358
|
-
/** Point to the inverse side property name. */
|
|
359
|
-
inversedBy(inversedBy: (string & keyof UnwrapRef<TargetValue>) | ((e: UnwrapRef<TargetValue>) => any)): ManyToOneOptionsBuilder<TargetValue>;
|
|
360
|
-
/** Wrap the entity in {@apilink Reference} wrapper. */
|
|
361
|
-
ref<T extends boolean = true>(ref?: T): ManyToOneOptionsBuilder<T extends true ? Reference<TargetValue> : UnwrapRef<TargetValue>>;
|
|
362
|
-
/** Use this relation as a primary key. */
|
|
363
|
-
primary(primary?: boolean): ManyToOneOptionsBuilder<TargetValue>;
|
|
352
|
+
updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
364
353
|
/** Map this relation to the primary key value instead of an entity. */
|
|
365
|
-
mapToPk(mapToPk?:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
/** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
369
|
-
joinColumns(...joinColumns: string[]): ManyToOneOptionsBuilder<TargetValue>;
|
|
370
|
-
/** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
|
|
371
|
-
ownColumns(...ownColumns: string[]): ManyToOneOptionsBuilder<TargetValue>;
|
|
372
|
-
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
373
|
-
referenceColumnName(referenceColumnName: string): ManyToOneOptionsBuilder<TargetValue>;
|
|
374
|
-
/** 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. */
|
|
375
|
-
referencedColumnNames(...referencedColumnNames: string[]): ManyToOneOptionsBuilder<TargetValue>;
|
|
376
|
-
/** What to do when the target entity gets deleted. */
|
|
377
|
-
deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToOneOptionsBuilder<TargetValue>;
|
|
378
|
-
/** What to do when the reference to the target entity gets updated. */
|
|
379
|
-
updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToOneOptionsBuilder<TargetValue>;
|
|
354
|
+
mapToPk<T extends boolean = true>(mapToPk?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'mapToPk'> & {
|
|
355
|
+
mapToPk: T;
|
|
356
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
380
357
|
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
381
|
-
deferMode(deferMode: DeferMode | `${DeferMode}`):
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
} & OneToManyOptions<any, UnwrapCollection<TargetValue>>);
|
|
389
|
-
constructor(options: OneToManyOptionsBuilder<TargetValue>['~options']);
|
|
358
|
+
deferMode(deferMode: DeferMode | `${DeferMode}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
359
|
+
/** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
|
|
360
|
+
ownColumns(...ownColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
361
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
362
|
+
createForeignKeyConstraint(createForeignKeyConstraint?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
363
|
+
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
364
|
+
foreignKeyName(foreignKeyName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
390
365
|
/** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
|
|
391
|
-
orphanRemoval(orphanRemoval?: boolean):
|
|
392
|
-
|
|
393
|
-
orderBy(orderBy: QueryOrderMap<UnwrapCollection<TargetValue>> | QueryOrderMap<UnwrapCollection<TargetValue>>[]): OneToManyOptionsBuilder<TargetValue>;
|
|
394
|
-
/** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
|
|
395
|
-
where(where: FilterQuery<UnwrapCollection<TargetValue>>): OneToManyOptionsBuilder<TargetValue>;
|
|
396
|
-
/** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
397
|
-
joinColumn(joinColumn: string): OneToManyOptionsBuilder<TargetValue>;
|
|
398
|
-
/** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
399
|
-
joinColumns(...joinColumns: string[]): OneToManyOptionsBuilder<TargetValue>;
|
|
400
|
-
/** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
401
|
-
inverseJoinColumn(inverseJoinColumn: string): OneToManyOptionsBuilder<TargetValue>;
|
|
402
|
-
/** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
403
|
-
inverseJoinColumns(...inverseJoinColumns: string[]): OneToManyOptionsBuilder<TargetValue>;
|
|
404
|
-
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
405
|
-
referenceColumnName(referenceColumnName: string): OneToManyOptionsBuilder<TargetValue>;
|
|
406
|
-
/** 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. */
|
|
407
|
-
referencedColumnNames(...referencedColumnNames: string[]): OneToManyOptionsBuilder<TargetValue>;
|
|
366
|
+
orphanRemoval(orphanRemoval?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
367
|
+
accessor(accessor?: string | boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
408
368
|
}
|
|
409
|
-
|
|
410
|
-
export declare class OneToManyOptionsBuilderOnlyMappedBy<TargetValue extends object> {
|
|
411
|
-
'~options': ({
|
|
412
|
-
kind: '1:m';
|
|
413
|
-
entity: () => EntitySchema<TargetValue>;
|
|
414
|
-
} & Omit<OneToManyOptions<any, UnwrapCollection<TargetValue>>, 'mappedBy'>);
|
|
415
|
-
constructor(options: OneToManyOptionsBuilderOnlyMappedBy<TargetValue>['~options']);
|
|
416
|
-
/** Point to the owning side property name. */
|
|
417
|
-
mappedBy(mappedBy: (AnyString & keyof UnwrapCollection<TargetValue>) | ((e: UnwrapCollection<TargetValue>) => any)): OneToManyOptionsBuilder<TargetValue>;
|
|
369
|
+
export interface EmptyOptions extends Partial<Record<UniversalPropertyKeys, unknown>> {
|
|
418
370
|
}
|
|
419
371
|
/** @internal */
|
|
420
|
-
export declare class
|
|
421
|
-
'
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
owner(owner?: boolean): OneToOneOptionsBuilder<TargetValue>;
|
|
428
|
-
/** Point to the inverse side property name. */
|
|
429
|
-
inversedBy(inversedBy: (string & keyof UnwrapRef<TargetValue>) | ((e: UnwrapRef<TargetValue>) => any)): OneToOneOptionsBuilder<TargetValue>;
|
|
430
|
-
/** Wrap the entity in {@apilink Reference} wrapper. */
|
|
431
|
-
ref<T extends boolean = true>(ref?: T): OneToOneOptionsBuilder<T extends true ? Reference<TargetValue> : UnwrapRef<TargetValue>>;
|
|
432
|
-
/** Use this relation as a primary key. */
|
|
433
|
-
primary(primary?: boolean): OneToOneOptionsBuilder<TargetValue>;
|
|
434
|
-
/** Map this relation to the primary key value instead of an entity. */
|
|
435
|
-
mapToPk(mapToPk?: boolean): OneToOneOptionsBuilder<TargetValue>;
|
|
436
|
-
/** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
|
|
437
|
-
ownColumns(...ownColumns: string[]): OneToOneOptionsBuilder<TargetValue>;
|
|
438
|
-
/** What to do when the target entity gets deleted. */
|
|
439
|
-
deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): OneToOneOptionsBuilder<TargetValue>;
|
|
440
|
-
/** What to do when the reference to the target entity gets updated. */
|
|
441
|
-
updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): OneToOneOptionsBuilder<TargetValue>;
|
|
442
|
-
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
443
|
-
deferMode(deferMode: DeferMode | `${DeferMode}`): OneToOneOptionsBuilder<TargetValue>;
|
|
372
|
+
export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> extends UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
|
|
373
|
+
kind: '1:m';
|
|
374
|
+
}, IncludeKeysForOneToManyOptions> {
|
|
375
|
+
/** Point to the owning side property name. */
|
|
376
|
+
mappedBy(mappedBy: (AnyString & keyof Value) | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
|
|
377
|
+
kind: '1:m';
|
|
378
|
+
}, IncludeKeysForOneToManyOptions>, IncludeKeysForOneToManyOptions>;
|
|
444
379
|
}
|
|
380
|
+
type EntityTarget = {
|
|
381
|
+
'~entity': any;
|
|
382
|
+
} | EntityClass;
|
|
445
383
|
declare const propertyBuilders: {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
384
|
+
bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
|
|
385
|
+
array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
|
|
386
|
+
decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
|
|
387
|
+
json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
388
|
+
formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
389
|
+
datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
|
|
390
|
+
time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
|
|
391
|
+
type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
392
|
+
enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
|
|
393
|
+
embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions, IncludeKeysForEmbeddedOptions>;
|
|
394
|
+
manyToMany: <Target extends EntityTarget>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
|
|
395
|
+
kind: "m:n";
|
|
396
|
+
}, IncludeKeysForManyToManyOptions>;
|
|
397
|
+
manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
398
|
+
kind: "m:1";
|
|
399
|
+
}, IncludeKeysForManyToOneOptions>;
|
|
400
|
+
oneToMany: <Target extends EntityTarget>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
|
|
401
|
+
oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
402
|
+
kind: "1:1";
|
|
403
|
+
}, IncludeKeysForOneToOneOptions>;
|
|
404
|
+
date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
405
|
+
blob: () => UniversalPropertyOptionsBuilder<NonNullable<Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
|
|
406
|
+
uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
|
|
407
|
+
enumArray: () => UniversalPropertyOptionsBuilder<(string | number)[], EmptyOptions, IncludeKeysForProperty>;
|
|
408
|
+
integer: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
409
|
+
smallint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
410
|
+
tinyint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
411
|
+
mediumint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
412
|
+
float: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
413
|
+
double: () => UniversalPropertyOptionsBuilder<NonNullable<string | number>, EmptyOptions, IncludeKeysForProperty>;
|
|
414
|
+
boolean: () => UniversalPropertyOptionsBuilder<NonNullable<boolean | null | undefined>, EmptyOptions, IncludeKeysForProperty>;
|
|
415
|
+
character: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
416
|
+
string: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
417
|
+
uuid: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
418
|
+
text: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
419
|
+
interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
420
|
+
unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
|
|
477
421
|
};
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
422
|
+
/** Own keys + base entity keys (when TBase is not `never`). Guards against `keyof never = string | number | symbol`. */
|
|
423
|
+
type AllKeys<TProperties, TBase> = keyof TProperties | (IsNever<TBase> extends true ? never : keyof TBase);
|
|
424
|
+
export interface EntityMetadataWithProperties<TName extends string, TTableName extends string, TProperties extends Record<string, any>, TPK extends (keyof TProperties)[] | undefined = undefined, TBase = never, TRepository = never> extends Omit<Partial<EntityMetadata<InferEntityFromProperties<TProperties, TPK, TBase, TRepository>>>, 'properties' | 'extends' | 'primaryKeys' | 'hooks' | 'discriminatorColumn' | 'versionProperty' | 'concurrencyCheckKeys' | 'serializedPrimaryKey' | 'indexes' | 'uniques' | 'repository' | 'orderBy'> {
|
|
425
|
+
name: TName;
|
|
426
|
+
tableName?: TTableName;
|
|
427
|
+
extends?: {
|
|
428
|
+
'~entity': TBase;
|
|
429
|
+
} | EntityCtor<TBase>;
|
|
430
|
+
properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
|
|
431
|
+
primaryKeys?: TPK & InferPrimaryKey<TProperties>[];
|
|
432
|
+
hooks?: DefineEntityHooks;
|
|
433
|
+
repository?: () => TRepository;
|
|
434
|
+
inheritance?: 'tpt';
|
|
435
|
+
orderBy?: {
|
|
436
|
+
[K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
|
|
437
|
+
} | {
|
|
438
|
+
[K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
|
|
439
|
+
}[];
|
|
440
|
+
discriminatorColumn?: string;
|
|
441
|
+
versionProperty?: AllKeys<TProperties, TBase>;
|
|
442
|
+
concurrencyCheckKeys?: Set<AllKeys<TProperties, TBase>>;
|
|
443
|
+
serializedPrimaryKey?: AllKeys<TProperties, TBase>;
|
|
444
|
+
indexes?: {
|
|
445
|
+
properties?: keyof TProperties | (keyof TProperties)[];
|
|
446
|
+
name?: string;
|
|
447
|
+
type?: string;
|
|
448
|
+
options?: Dictionary;
|
|
449
|
+
expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
|
|
450
|
+
}[];
|
|
451
|
+
uniques?: {
|
|
452
|
+
properties?: keyof TProperties | (keyof TProperties)[];
|
|
453
|
+
name?: string;
|
|
454
|
+
options?: Dictionary;
|
|
455
|
+
expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
|
|
456
|
+
deferMode?: DeferMode | `${DeferMode}`;
|
|
457
|
+
}[];
|
|
458
|
+
}
|
|
459
|
+
export declare function defineEntity<const TName extends string, const TTableName extends string, const TProperties extends Record<string, any>, const TPK extends (keyof TProperties)[] | undefined = undefined, const TBase = never, const TRepository = never>(meta: EntityMetadataWithProperties<TName, TTableName, TProperties, TPK, TBase, TRepository>): EntitySchemaWithMeta<TName, TTableName, InferEntityFromProperties<TProperties, TPK, TBase, TRepository>, TBase, TProperties>;
|
|
460
|
+
export declare function defineEntity<const TEntity = any, const TProperties extends Record<string, any> = Record<string, any>, const TClassName extends string = string, const TTableName extends string = string, const TBase = never, const TClass extends EntityCtor = EntityCtor<TEntity>>(meta: Omit<Partial<EntityMetadata<TEntity>>, 'properties' | 'extends' | 'className' | 'tableName' | 'hooks'> & {
|
|
461
|
+
class: TClass;
|
|
462
|
+
className?: TClassName;
|
|
463
|
+
tableName?: TTableName;
|
|
464
|
+
extends?: TBase;
|
|
465
|
+
properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
|
|
466
|
+
hooks?: DefineEntityHooks<TEntity>;
|
|
467
|
+
}): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
|
|
482
468
|
export declare namespace defineEntity {
|
|
483
469
|
var properties: {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
470
|
+
bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
|
|
471
|
+
array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
|
|
472
|
+
decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
|
|
473
|
+
json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
474
|
+
formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
475
|
+
datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
|
|
476
|
+
time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
|
|
477
|
+
type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
478
|
+
enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
|
|
479
|
+
embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions, IncludeKeysForEmbeddedOptions>;
|
|
480
|
+
manyToMany: <Target extends EntityTarget>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
|
|
481
|
+
kind: "m:n";
|
|
482
|
+
}, IncludeKeysForManyToManyOptions>;
|
|
483
|
+
manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
484
|
+
kind: "m:1";
|
|
485
|
+
}, IncludeKeysForManyToOneOptions>;
|
|
486
|
+
oneToMany: <Target extends EntityTarget>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
|
|
487
|
+
oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
488
|
+
kind: "1:1";
|
|
489
|
+
}, IncludeKeysForOneToOneOptions>;
|
|
490
|
+
date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
491
|
+
blob: () => UniversalPropertyOptionsBuilder<NonNullable<Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
|
|
492
|
+
uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
|
|
493
|
+
enumArray: () => UniversalPropertyOptionsBuilder<(string | number)[], EmptyOptions, IncludeKeysForProperty>;
|
|
494
|
+
integer: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
495
|
+
smallint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
496
|
+
tinyint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
497
|
+
mediumint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
498
|
+
float: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
|
|
499
|
+
double: () => UniversalPropertyOptionsBuilder<NonNullable<string | number>, EmptyOptions, IncludeKeysForProperty>;
|
|
500
|
+
boolean: () => UniversalPropertyOptionsBuilder<NonNullable<boolean | null | undefined>, EmptyOptions, IncludeKeysForProperty>;
|
|
501
|
+
character: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
502
|
+
string: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
503
|
+
uuid: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
504
|
+
text: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
505
|
+
interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
506
|
+
unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
|
|
515
507
|
};
|
|
516
508
|
}
|
|
509
|
+
export { propertyBuilders as p };
|
|
510
|
+
type EntityHookValue<T, K extends keyof EventSubscriber<T>> = (keyof T | NonNullable<EventSubscriber<T>[K]>)[];
|
|
511
|
+
export interface DefineEntityHooks<T = any> {
|
|
512
|
+
onInit?: EntityHookValue<T, 'onInit'>;
|
|
513
|
+
onLoad?: EntityHookValue<T, 'onLoad'>;
|
|
514
|
+
beforeCreate?: EntityHookValue<T, 'beforeCreate'>;
|
|
515
|
+
afterCreate?: EntityHookValue<T, 'afterCreate'>;
|
|
516
|
+
beforeUpdate?: EntityHookValue<T, 'beforeUpdate'>;
|
|
517
|
+
afterUpdate?: EntityHookValue<T, 'afterUpdate'>;
|
|
518
|
+
beforeUpsert?: EntityHookValue<T, 'beforeUpsert'>;
|
|
519
|
+
afterUpsert?: EntityHookValue<T, 'afterUpsert'>;
|
|
520
|
+
beforeDelete?: EntityHookValue<T, 'beforeDelete'>;
|
|
521
|
+
afterDelete?: EntityHookValue<T, 'afterDelete'>;
|
|
522
|
+
}
|
|
517
523
|
type PropertyValueType = PropertyOptions<any>['type'];
|
|
518
524
|
type InferPropertyValueType<T extends PropertyValueType> = T extends string ? InferTypeByString<T> : T extends NumberConstructor ? number : T extends StringConstructor ? string : T extends BooleanConstructor ? boolean : T extends DateConstructor ? Date : T extends ArrayConstructor ? string[] : T extends Constructor<infer TType> ? TType extends Type<infer TValue, any> ? NonNullable<TValue> : TType : T extends Type<infer TValue, any> ? NonNullable<TValue> : any;
|
|
519
525
|
type InferTypeByString<T extends string> = T extends keyof typeof types ? InferJSType<typeof types[T]> : InferColumnType<T>;
|
|
520
526
|
type InferJSType<T> = T extends typeof Type<infer TValue, any> ? NonNullable<TValue> : never;
|
|
521
527
|
type InferColumnType<T extends string> = T extends 'int' | 'int4' | 'integer' | 'bigint' | 'int8' | 'int2' | 'tinyint' | 'smallint' | 'mediumint' ? number : T extends 'double' | 'double precision' | 'real' | 'float8' | 'decimal' | 'numeric' | 'float' | 'float4' ? number : T extends 'datetime' | 'time' | 'time with time zone' | 'timestamp' | 'timestamp with time zone' | 'timetz' | 'timestamptz' | 'date' | 'interval' ? Date : T extends 'ObjectId' | 'objectId' | 'character varying' | 'varchar' | 'char' | 'character' | 'uuid' | 'text' | 'tinytext' | 'mediumtext' | 'longtext' | 'enum' ? string : T extends 'boolean' | 'bool' | 'bit' ? boolean : T extends 'blob' | 'tinyblob' | 'mediumblob' | 'longblob' | 'bytea' ? Buffer : T extends 'point' | 'line' | 'lseg' | 'box' | 'circle' | 'path' | 'polygon' | 'geometry' ? number[] : T extends 'tsvector' | 'tsquery' ? string[] : T extends 'json' | 'jsonb' ? any : any;
|
|
522
|
-
export type InferEntityFromProperties<Properties extends Record<string, any
|
|
523
|
-
-readonly [K in keyof Properties]:
|
|
524
|
-
}
|
|
528
|
+
export type InferEntityFromProperties<Properties extends Record<string, any>, PK extends (keyof Properties)[] | undefined = undefined, Base = never, Repository = never> = {
|
|
529
|
+
-readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
|
|
530
|
+
} & {
|
|
531
|
+
[PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
|
|
532
|
+
} & (IsNever<Repository> extends true ? {} : {
|
|
533
|
+
[EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
|
|
534
|
+
}) & (IsNever<Base> extends true ? {} : Omit<Base, typeof PrimaryKeyProp>);
|
|
535
|
+
type InferCombinedPrimaryKey<Properties extends Record<string, any>, PK, Base> = PK extends undefined ? CombinePrimaryKeys<InferPrimaryKey<Properties>, ExtractBasePrimaryKey<Base>> : PK;
|
|
536
|
+
type ExtractBasePrimaryKey<Base> = Base extends {
|
|
537
|
+
[PrimaryKeyProp]?: infer BasePK;
|
|
538
|
+
} ? BasePK : never;
|
|
539
|
+
type CombinePrimaryKeys<ChildPK, BasePK> = [
|
|
540
|
+
ChildPK
|
|
541
|
+
] extends [never] ? BasePK : [BasePK] extends [never] ? IsUnion<ChildPK> extends true ? ChildPK[] : ChildPK : ChildPK | BasePK;
|
|
542
|
+
export type InferPrimaryKey<Properties extends Record<string, any>> = {
|
|
543
|
+
[K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
|
|
544
|
+
'~options': {
|
|
545
|
+
primary: true;
|
|
546
|
+
};
|
|
547
|
+
} ? K : never;
|
|
548
|
+
}[keyof Properties];
|
|
525
549
|
type InferBuilderValue<Builder> = Builder extends {
|
|
526
550
|
'~type'?: {
|
|
527
|
-
value: infer
|
|
551
|
+
value: infer Value;
|
|
528
552
|
};
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
type
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
type
|
|
553
|
+
'~options'?: infer Options;
|
|
554
|
+
} ? MaybeHidden<MaybeOpt<MaybeScalarRef<MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Options>, Options>, Options>, Options>, Options>, Options>, Options> : never;
|
|
555
|
+
type MaybeArray<Value, Options> = Options extends {
|
|
556
|
+
array: true;
|
|
557
|
+
} ? Value[] : Value;
|
|
558
|
+
type MaybeMapToPk<Value, Options> = Options extends {
|
|
559
|
+
mapToPk: true;
|
|
560
|
+
} ? Primary<Value> : Value;
|
|
561
|
+
type MaybeNullable<Value, Options> = Options extends {
|
|
562
|
+
nullable: true;
|
|
563
|
+
} ? Value | null | undefined : Value;
|
|
564
|
+
type MaybeRelationRef<Value, Options> = Options extends {
|
|
565
|
+
mapToPk: true;
|
|
566
|
+
} ? Value : Options extends {
|
|
567
|
+
ref: false;
|
|
568
|
+
} ? Value : Options extends {
|
|
569
|
+
ref: true;
|
|
570
|
+
kind: '1:1';
|
|
571
|
+
} ? Value extends object ? Ref<Value> : never : Options extends {
|
|
572
|
+
ref: true;
|
|
573
|
+
kind: 'm:1';
|
|
574
|
+
} ? Value extends object ? Ref<Value> : never : Options extends {
|
|
575
|
+
kind: '1:m';
|
|
576
|
+
} ? Value extends object ? Collection<Value> : never : Options extends {
|
|
577
|
+
kind: 'm:n';
|
|
578
|
+
} ? Value extends object ? Collection<Value> : never : Value;
|
|
579
|
+
type MaybeScalarRef<Value, Options> = Options extends {
|
|
580
|
+
ref: false;
|
|
581
|
+
} ? Value : Options extends {
|
|
582
|
+
kind: '1:1' | 'm:1' | '1:m' | 'm:n';
|
|
583
|
+
} ? Value : Options extends {
|
|
584
|
+
ref: true;
|
|
585
|
+
} ? ScalarReference<Value> : Value;
|
|
586
|
+
type MaybeOpt<Value, Options> = Options extends {
|
|
587
|
+
mapToPk: true;
|
|
588
|
+
} ? Value extends Opt<infer OriginalValue> ? OriginalValue : Value : Options extends {
|
|
589
|
+
autoincrement: true;
|
|
590
|
+
} | {
|
|
591
|
+
onCreate: Function;
|
|
592
|
+
} | {
|
|
593
|
+
default: string | string[] | number | number[] | boolean | null | Date | Raw;
|
|
594
|
+
} | {
|
|
595
|
+
defaultRaw: string;
|
|
596
|
+
} | {
|
|
597
|
+
persist: false;
|
|
598
|
+
} | {
|
|
599
|
+
version: true;
|
|
600
|
+
} | {
|
|
601
|
+
formula: string | ((...args: any[]) => any);
|
|
602
|
+
} ? Opt<Value> : Value;
|
|
603
|
+
type MaybeHidden<Value, Options> = Options extends {
|
|
604
|
+
hidden: true;
|
|
605
|
+
} ? Hidden<Value> : Value;
|
|
535
606
|
type ValueOf<T extends Dictionary> = T[keyof T];
|
|
536
|
-
|
|
537
|
-
export {};
|
|
607
|
+
type IsUnion<T, U = T> = T extends U ? ([U] extends [T] ? false : true) : false;
|