@mikro-orm/core 7.0.0-dev.7 → 7.0.0-dev.71
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 +85 -42
- package/EntityManager.js +282 -194
- package/MikroORM.d.ts +11 -29
- package/MikroORM.js +33 -127
- package/README.md +3 -2
- package/cache/FileCacheAdapter.js +1 -2
- package/connections/Connection.d.ts +11 -7
- package/connections/Connection.js +16 -14
- package/drivers/DatabaseDriver.d.ts +11 -5
- package/drivers/DatabaseDriver.js +13 -4
- package/drivers/IDatabaseDriver.d.ts +27 -5
- package/entity/BaseEntity.d.ts +0 -1
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +98 -30
- package/entity/Collection.js +432 -93
- package/entity/EntityAssigner.d.ts +1 -1
- package/entity/EntityAssigner.js +9 -1
- package/entity/EntityFactory.d.ts +7 -0
- package/entity/EntityFactory.js +63 -40
- package/entity/EntityHelper.js +26 -9
- package/entity/EntityLoader.d.ts +5 -4
- package/entity/EntityLoader.js +69 -36
- package/entity/EntityRepository.d.ts +1 -1
- package/entity/EntityValidator.js +4 -4
- package/entity/Reference.d.ts +9 -7
- package/entity/Reference.js +32 -5
- package/entity/WrappedEntity.d.ts +0 -2
- package/entity/WrappedEntity.js +1 -5
- package/entity/defineEntity.d.ts +549 -0
- package/entity/defineEntity.js +529 -0
- package/entity/index.d.ts +2 -1
- package/entity/index.js +2 -1
- package/entity/utils.d.ts +7 -0
- package/entity/utils.js +15 -3
- package/enums.d.ts +20 -5
- package/enums.js +13 -0
- package/errors.d.ts +6 -1
- package/errors.js +14 -4
- package/events/EventSubscriber.d.ts +3 -1
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +35 -24
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/SimpleLogger.d.ts +1 -1
- package/metadata/EntitySchema.d.ts +9 -13
- package/metadata/EntitySchema.js +44 -26
- package/metadata/MetadataDiscovery.d.ts +6 -7
- package/metadata/MetadataDiscovery.js +161 -162
- package/metadata/MetadataProvider.d.ts +2 -2
- package/metadata/MetadataProvider.js +15 -0
- package/metadata/MetadataStorage.d.ts +0 -4
- package/metadata/MetadataStorage.js +6 -10
- package/metadata/MetadataValidator.d.ts +0 -7
- package/metadata/MetadataValidator.js +4 -13
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +39 -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 +7 -1
- package/naming-strategy/NamingStrategy.d.ts +11 -1
- package/package.json +11 -10
- package/platforms/Platform.d.ts +6 -10
- package/platforms/Platform.js +6 -22
- package/serialization/EntitySerializer.d.ts +2 -0
- package/serialization/EntitySerializer.js +29 -11
- package/serialization/EntityTransformer.js +22 -12
- package/serialization/SerializationContext.js +14 -11
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +1 -2
- package/types/BigIntType.d.ts +8 -6
- 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 +1 -1
- package/types/DoubleType.js +1 -1
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/Type.d.ts +2 -1
- package/types/Type.js +1 -1
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/Uint8ArrayType.js +0 -3
- package/types/index.d.ts +1 -1
- package/typings.d.ts +112 -77
- package/typings.js +32 -32
- package/unit-of-work/ChangeSetComputer.js +8 -3
- package/unit-of-work/ChangeSetPersister.d.ts +4 -2
- package/unit-of-work/ChangeSetPersister.js +37 -16
- package/unit-of-work/UnitOfWork.d.ts +8 -1
- package/unit-of-work/UnitOfWork.js +111 -54
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +10 -8
- package/utils/Configuration.d.ts +200 -191
- package/utils/Configuration.js +141 -152
- package/utils/ConfigurationLoader.d.ts +3 -44
- package/utils/ConfigurationLoader.js +26 -239
- package/utils/Cursor.d.ts +3 -3
- package/utils/Cursor.js +3 -0
- package/utils/DataloaderUtils.d.ts +15 -5
- package/utils/DataloaderUtils.js +53 -7
- package/utils/EntityComparator.d.ts +8 -4
- package/utils/EntityComparator.js +107 -60
- package/utils/QueryHelper.d.ts +9 -1
- package/utils/QueryHelper.js +69 -8
- package/utils/RawQueryFragment.d.ts +36 -4
- package/utils/RawQueryFragment.js +34 -13
- package/utils/TransactionManager.d.ts +65 -0
- package/utils/TransactionManager.js +223 -0
- package/utils/Utils.d.ts +17 -84
- package/utils/Utils.js +132 -252
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/upsert-utils.d.ts +7 -2
- package/utils/upsert-utils.js +52 -1
- 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/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/BaseEntity.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { type SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
|
6
6
|
import type { FindOneOptions } from '../drivers/IDatabaseDriver.js';
|
|
7
7
|
export declare abstract class BaseEntity {
|
|
8
8
|
isInitialized(): boolean;
|
|
9
|
-
isTouched(): boolean;
|
|
10
9
|
populated(populated?: boolean): void;
|
|
11
10
|
populate<Entity extends this = this, Hint extends string = never>(populate: AutoPath<Entity, Hint>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
12
11
|
toReference<Entity extends this = this>(): Ref<Entity> & LoadedReference<Loaded<Entity, AddEager<Entity>>>;
|
package/entity/BaseEntity.js
CHANGED
package/entity/Collection.d.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
|
+
import type { EntityDTO, EntityKey, EntityProperty, FilterQuery, IPrimaryKey, Loaded, LoadedCollection, Populate, Primary } from '../typings.js';
|
|
3
3
|
import { Reference } from './Reference.js';
|
|
4
4
|
import type { Transaction } from '../connections/Connection.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { CountOptions, FindOptions } from '../drivers/IDatabaseDriver.js';
|
|
6
6
|
import type { EntityLoaderOptions } from './EntityLoader.js';
|
|
7
7
|
export interface MatchingOptions<T extends object, P extends string = never> extends FindOptions<T, P> {
|
|
8
8
|
where?: FilterQuery<T>;
|
|
9
9
|
store?: boolean;
|
|
10
10
|
ctx?: Transaction;
|
|
11
11
|
}
|
|
12
|
-
export declare class Collection<T extends object, O extends object = object>
|
|
12
|
+
export declare class Collection<T extends object, O extends object = object> {
|
|
13
|
+
readonly owner: O;
|
|
14
|
+
[k: number]: T;
|
|
15
|
+
protected readonly items: Set<T>;
|
|
16
|
+
protected initialized: boolean;
|
|
17
|
+
protected dirty: boolean;
|
|
18
|
+
protected partial: boolean;
|
|
19
|
+
protected snapshot: T[] | undefined;
|
|
13
20
|
private readonly?;
|
|
21
|
+
protected _count?: number;
|
|
22
|
+
private _property?;
|
|
14
23
|
private _populated?;
|
|
15
|
-
private _snapshot?;
|
|
16
24
|
constructor(owner: O, items?: T[], initialized?: boolean);
|
|
17
25
|
/**
|
|
18
26
|
* Creates new Collection instance, assigns it to the owning entity and sets the items to it (propagating them to their inverse sides)
|
|
@@ -39,59 +47,119 @@ export declare class Collection<T extends object, O extends object = object> ext
|
|
|
39
47
|
*/
|
|
40
48
|
getItems(check?: boolean): T[];
|
|
41
49
|
toJSON<TT extends T>(): EntityDTO<TT>[];
|
|
42
|
-
add<TT extends T>(entity: TT | Reference<TT> | Iterable<TT | Reference<TT>>, ...entities: (TT | Reference<TT>)[]):
|
|
50
|
+
add<TT extends T>(entity: TT | Reference<TT> | Iterable<TT | Reference<TT>>, ...entities: (TT | Reference<TT>)[]): number;
|
|
43
51
|
/**
|
|
44
|
-
*
|
|
52
|
+
* Remove specified item(s) from the collection. Note that removing item from collection does not necessarily imply deleting the target entity,
|
|
53
|
+
* it means we are disconnecting the relation - removing items from collection, not removing entities from database - `Collection.remove()`
|
|
54
|
+
* is not the same as `em.remove()`. If we want to delete the entity by removing it from collection, we need to enable `orphanRemoval: true`,
|
|
55
|
+
* which tells the ORM we don't want orphaned entities to exist, so we know those should be removed.
|
|
45
56
|
*/
|
|
46
|
-
remove<TT extends T>(entity: TT | Reference<TT> | Iterable<TT | Reference<TT>> | ((item: TT) => boolean), ...entities: (TT | Reference<TT>)[]):
|
|
57
|
+
remove<TT extends T>(entity: TT | Reference<TT> | Iterable<TT | Reference<TT>> | ((item: TT) => boolean), ...entities: (TT | Reference<TT>)[]): number;
|
|
47
58
|
contains<TT extends T>(item: TT | Reference<TT>, check?: boolean): boolean;
|
|
48
59
|
count(): number;
|
|
49
60
|
isEmpty(): boolean;
|
|
61
|
+
shouldPopulate(populated?: boolean): boolean;
|
|
62
|
+
populated(populated?: boolean | undefined): void;
|
|
63
|
+
init<TT extends T, P extends string = never>(options?: InitCollectionOptions<TT, P>): Promise<LoadedCollection<Loaded<TT, P>>>;
|
|
64
|
+
private getEntityManager;
|
|
65
|
+
private createCondition;
|
|
66
|
+
private createOrderBy;
|
|
67
|
+
private createManyToManyCondition;
|
|
68
|
+
private createLoadCountCondition;
|
|
69
|
+
private checkInitialized;
|
|
70
|
+
/**
|
|
71
|
+
* re-orders items after searching with `$in` operator
|
|
72
|
+
*/
|
|
73
|
+
private reorderItems;
|
|
74
|
+
private cancelOrphanRemoval;
|
|
75
|
+
private validateModification;
|
|
76
|
+
toArray<TT extends T>(): EntityDTO<TT>[];
|
|
77
|
+
getIdentifiers<U extends IPrimaryKey = Primary<T> & IPrimaryKey>(field?: string | string[]): U[];
|
|
78
|
+
/**
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
addWithoutPropagation(entity: T): void;
|
|
82
|
+
set(items: Iterable<T | Reference<T>>): void;
|
|
83
|
+
private compare;
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
hydrate(items: T[], forcePropagate?: boolean, partial?: boolean): void;
|
|
88
|
+
/**
|
|
89
|
+
* Remove all items from the collection. Note that removing items from collection does not necessarily imply deleting the target entity,
|
|
90
|
+
* it means we are disconnecting the relation - removing items from collection, not removing entities from database - `Collection.remove()`
|
|
91
|
+
* is not the same as `em.remove()`. If we want to delete the entity by removing it from collection, we need to enable `orphanRemoval: true`,
|
|
92
|
+
* which tells the ORM we don't want orphaned entities to exist, so we know those should be removed.
|
|
93
|
+
*/
|
|
94
|
+
removeAll(): void;
|
|
95
|
+
/**
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
removeWithoutPropagation(entity: T): void;
|
|
50
99
|
/**
|
|
51
|
-
*
|
|
100
|
+
* Extracts a slice of the collection items starting at position start to end (exclusive) of the collection.
|
|
101
|
+
* If end is null it returns all elements from start to the end of the collection.
|
|
52
102
|
*/
|
|
53
103
|
slice(start?: number, end?: number): T[];
|
|
54
104
|
/**
|
|
55
|
-
*
|
|
105
|
+
* Tests for the existence of an element that satisfies the given predicate.
|
|
56
106
|
*/
|
|
57
107
|
exists(cb: (item: T) => boolean): boolean;
|
|
58
108
|
/**
|
|
59
|
-
*
|
|
109
|
+
* Returns the first element of this collection that satisfies the predicate.
|
|
60
110
|
*/
|
|
61
111
|
find(cb: (item: T, index: number) => boolean): T | undefined;
|
|
62
112
|
/**
|
|
63
|
-
*
|
|
113
|
+
* Extracts a subset of the collection items.
|
|
64
114
|
*/
|
|
65
115
|
filter(cb: (item: T, index: number) => boolean): T[];
|
|
66
116
|
/**
|
|
67
|
-
*
|
|
117
|
+
* Maps the collection items based on your provided mapper function.
|
|
68
118
|
*/
|
|
69
119
|
map<R>(mapper: (item: T, index: number) => R): R[];
|
|
70
120
|
/**
|
|
71
|
-
*
|
|
121
|
+
* Maps the collection items based on your provided mapper function to a single object.
|
|
122
|
+
*/
|
|
123
|
+
reduce<R>(cb: (obj: R, item: T, index: number) => R, initial?: R): R;
|
|
124
|
+
/**
|
|
125
|
+
* Maps the collection items to a dictionary, indexed by the key you specify.
|
|
126
|
+
* If there are more items with the same key, only the first one will be present.
|
|
72
127
|
*/
|
|
73
128
|
indexBy<K1 extends keyof T, K2 extends keyof T = never>(key: K1): Record<T[K1] & PropertyKey, T>;
|
|
74
129
|
/**
|
|
75
|
-
*
|
|
130
|
+
* Maps the collection items to a dictionary, indexed by the key you specify.
|
|
131
|
+
* If there are more items with the same key, only the first one will be present.
|
|
76
132
|
*/
|
|
77
133
|
indexBy<K1 extends keyof T, K2 extends keyof T = never>(key: K1, valueKey: K2): Record<T[K1] & PropertyKey, T[K2]>;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
private createManyToManyCondition;
|
|
85
|
-
private createLoadCountCondition;
|
|
86
|
-
private modify;
|
|
87
|
-
private checkInitialized;
|
|
134
|
+
isInitialized(fully?: boolean): boolean;
|
|
135
|
+
isDirty(): boolean;
|
|
136
|
+
isPartial(): boolean;
|
|
137
|
+
setDirty(dirty?: boolean): void;
|
|
138
|
+
get length(): number;
|
|
139
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
88
140
|
/**
|
|
89
|
-
*
|
|
141
|
+
* @internal
|
|
90
142
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
143
|
+
takeSnapshot(forcePropagate?: boolean): void;
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
getSnapshot(): T[] | undefined;
|
|
148
|
+
/**
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
get property(): EntityProperty;
|
|
152
|
+
/**
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
set property(prop: EntityProperty);
|
|
156
|
+
protected propagate(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
157
|
+
protected propagateToInverseSide(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
158
|
+
protected propagateToOwningSide(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
159
|
+
protected shouldPropagateToCollection(collection: Collection<O, T>, method: 'add' | 'remove' | 'takeSnapshot'): boolean;
|
|
160
|
+
protected incrementCount(value: number): void;
|
|
161
|
+
/** @ignore */
|
|
162
|
+
[inspect.custom](depth?: number): string;
|
|
95
163
|
}
|
|
96
164
|
export interface InitCollectionOptions<T, P extends string = never, F extends string = '*', E extends string = never> extends EntityLoaderOptions<T, F, E> {
|
|
97
165
|
dataloader?: boolean;
|