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