@mikro-orm/core 7.0.0-dev.33 → 7.0.0-dev.331
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 +70 -75
- package/EntityManager.js +487 -402
- package/MikroORM.d.ts +45 -38
- package/MikroORM.js +123 -156
- package/README.md +7 -4
- package/cache/FileCacheAdapter.d.ts +2 -7
- package/cache/FileCacheAdapter.js +35 -30
- package/cache/GeneratedCacheAdapter.d.ts +1 -2
- package/cache/GeneratedCacheAdapter.js +6 -8
- package/cache/MemoryCacheAdapter.d.ts +1 -2
- package/cache/MemoryCacheAdapter.js +8 -8
- package/cache/index.d.ts +1 -2
- package/cache/index.js +0 -2
- package/connections/Connection.d.ts +12 -5
- package/connections/Connection.js +37 -15
- package/drivers/DatabaseDriver.d.ts +25 -18
- package/drivers/DatabaseDriver.js +144 -45
- package/drivers/IDatabaseDriver.d.ts +118 -23
- package/entity/BaseEntity.d.ts +63 -4
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +95 -31
- package/entity/Collection.js +487 -139
- package/entity/EntityAssigner.js +37 -25
- package/entity/EntityFactory.d.ts +8 -9
- package/entity/EntityFactory.js +152 -100
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +69 -27
- package/entity/EntityLoader.d.ts +12 -13
- package/entity/EntityLoader.js +286 -125
- package/entity/EntityRepository.d.ts +28 -8
- package/entity/EntityRepository.js +8 -2
- package/entity/PolymorphicRef.d.ts +12 -0
- package/entity/PolymorphicRef.js +18 -0
- package/entity/Reference.d.ts +3 -8
- package/entity/Reference.js +62 -29
- package/entity/WrappedEntity.d.ts +7 -10
- package/entity/WrappedEntity.js +6 -7
- package/entity/defineEntity.d.ts +472 -313
- package/entity/defineEntity.js +134 -290
- package/entity/index.d.ts +2 -2
- package/entity/index.js +2 -2
- package/entity/utils.d.ts +6 -1
- package/entity/utils.js +46 -11
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +66 -0
- package/enums.d.ts +8 -6
- package/enums.js +13 -17
- package/errors.d.ts +26 -16
- package/errors.js +63 -31
- package/events/EventManager.d.ts +3 -5
- package/events/EventManager.js +37 -26
- package/events/index.d.ts +1 -1
- package/events/index.js +0 -1
- package/exceptions.js +9 -2
- package/hydration/Hydrator.js +1 -2
- package/hydration/ObjectHydrator.d.ts +5 -6
- package/hydration/ObjectHydrator.js +109 -50
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +3 -4
- package/logging/SimpleLogger.d.ts +1 -1
- package/logging/colors.d.ts +1 -1
- package/logging/colors.js +4 -6
- package/logging/index.d.ts +2 -1
- package/logging/index.js +1 -1
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +11 -0
- package/metadata/EntitySchema.d.ts +47 -23
- package/metadata/EntitySchema.js +103 -34
- package/metadata/MetadataDiscovery.d.ts +65 -18
- package/metadata/MetadataDiscovery.js +940 -424
- package/metadata/MetadataProvider.d.ts +11 -2
- package/metadata/MetadataProvider.js +71 -2
- package/metadata/MetadataStorage.d.ts +11 -13
- package/metadata/MetadataStorage.js +79 -48
- package/metadata/MetadataValidator.d.ts +32 -9
- package/metadata/MetadataValidator.js +214 -44
- 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 +0 -1
- package/metadata/types.d.ts +577 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
- package/naming-strategy/AbstractNamingStrategy.js +26 -5
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
- package/naming-strategy/EntityCaseNamingStrategy.js +7 -6
- 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/naming-strategy/index.d.ts +1 -1
- package/naming-strategy/index.js +0 -1
- package/not-supported.d.ts +2 -0
- package/not-supported.js +8 -0
- package/package.json +47 -36
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +33 -15
- package/platforms/Platform.js +125 -69
- package/serialization/EntitySerializer.d.ts +6 -3
- package/serialization/EntitySerializer.js +54 -30
- package/serialization/EntityTransformer.js +37 -22
- package/serialization/SerializationContext.d.ts +10 -14
- package/serialization/SerializationContext.js +24 -19
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +2 -3
- 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.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/UuidType.d.ts +2 -0
- package/types/UuidType.js +14 -2
- package/types/index.d.ts +3 -2
- package/typings.d.ts +427 -170
- package/typings.js +100 -45
- package/unit-of-work/ChangeSet.d.ts +4 -6
- package/unit-of-work/ChangeSet.js +8 -9
- package/unit-of-work/ChangeSetComputer.d.ts +2 -12
- package/unit-of-work/ChangeSetComputer.js +61 -38
- package/unit-of-work/ChangeSetPersister.d.ts +10 -17
- package/unit-of-work/ChangeSetPersister.js +136 -73
- package/unit-of-work/CommitOrderCalculator.d.ts +13 -14
- package/unit-of-work/CommitOrderCalculator.js +22 -20
- package/unit-of-work/IdentityMap.d.ts +12 -3
- package/unit-of-work/IdentityMap.js +51 -13
- package/unit-of-work/UnitOfWork.d.ts +39 -23
- package/unit-of-work/UnitOfWork.js +441 -246
- package/utils/AbstractMigrator.d.ts +101 -0
- package/utils/AbstractMigrator.js +303 -0
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +30 -18
- package/utils/AsyncContext.d.ts +6 -0
- package/utils/AsyncContext.js +42 -0
- package/utils/Configuration.d.ts +647 -185
- package/utils/Configuration.js +215 -252
- package/utils/ConfigurationLoader.d.ts +1 -52
- package/utils/ConfigurationLoader.js +1 -330
- package/utils/Cursor.d.ts +3 -6
- package/utils/Cursor.js +32 -17
- package/utils/DataloaderUtils.d.ts +10 -5
- package/utils/DataloaderUtils.js +42 -22
- package/utils/EntityComparator.d.ts +21 -21
- package/utils/EntityComparator.js +224 -118
- package/utils/QueryHelper.d.ts +34 -7
- package/utils/QueryHelper.js +183 -72
- package/utils/RawQueryFragment.d.ts +28 -34
- package/utils/RawQueryFragment.js +37 -72
- package/utils/RequestContext.js +2 -2
- package/utils/TransactionContext.js +2 -2
- package/utils/TransactionManager.js +11 -8
- package/utils/Utils.d.ts +16 -127
- package/utils/Utils.js +104 -402
- package/utils/clone.js +13 -23
- package/utils/env-vars.d.ts +7 -0
- package/utils/env-vars.js +98 -0
- package/utils/fs-utils.d.ts +20 -0
- package/utils/fs-utils.js +193 -0
- package/utils/index.d.ts +1 -3
- package/utils/index.js +1 -3
- package/utils/upsert-utils.d.ts +9 -4
- package/utils/upsert-utils.js +51 -5
- 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/decorators/Property.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { MetadataStorage } from '../metadata/MetadataStorage.js';
|
|
2
|
-
import { MetadataValidator } from '../metadata/MetadataValidator.js';
|
|
3
|
-
import { Utils } from '../utils/Utils.js';
|
|
4
|
-
import { ReferenceKind } from '../enums.js';
|
|
5
|
-
export function Property(options = {}) {
|
|
6
|
-
return function (target, propertyName) {
|
|
7
|
-
const meta = MetadataStorage.getMetadataFromDecorator(target.constructor);
|
|
8
|
-
const desc = Object.getOwnPropertyDescriptor(target, propertyName) || {};
|
|
9
|
-
MetadataValidator.validateSingleDecorator(meta, propertyName, ReferenceKind.SCALAR);
|
|
10
|
-
const name = options.name || propertyName;
|
|
11
|
-
if (propertyName !== name && !(desc.value instanceof Function)) {
|
|
12
|
-
Utils.renameKey(options, 'name', 'fieldName');
|
|
13
|
-
}
|
|
14
|
-
options.name = propertyName;
|
|
15
|
-
const { check, ...opts } = options;
|
|
16
|
-
const prop = { kind: ReferenceKind.SCALAR, ...opts };
|
|
17
|
-
prop.getter = !!desc.get;
|
|
18
|
-
prop.setter = !!desc.set;
|
|
19
|
-
if (desc.value instanceof Function) {
|
|
20
|
-
prop.getter = true;
|
|
21
|
-
prop.persist = false;
|
|
22
|
-
prop.type = 'method';
|
|
23
|
-
prop.getterName = propertyName;
|
|
24
|
-
prop.name = name;
|
|
25
|
-
}
|
|
26
|
-
if (check) {
|
|
27
|
-
meta.checks.push({ property: prop.name, expression: check });
|
|
28
|
-
}
|
|
29
|
-
meta.properties[prop.name] = prop;
|
|
30
|
-
return Utils.propertyDecoratorReturnValue();
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TransactionOptions } from '../enums.js';
|
|
2
|
-
import type { ContextProvider } from '../typings.js';
|
|
3
|
-
type TransactionalOptions<T> = TransactionOptions & {
|
|
4
|
-
context?: ContextProvider<T>;
|
|
5
|
-
contextName?: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* This decorator wraps the method with `em.transactional()`, so you can provide `TransactionOptions` just like with `em.transactional()`.
|
|
9
|
-
* The difference is that you can specify the context in which the transaction begins by providing `context` option,
|
|
10
|
-
* and if omitted, the transaction will begin in the current context implicitly.
|
|
11
|
-
* It works on async functions and can be nested with `em.transactional()`.
|
|
12
|
-
*/
|
|
13
|
-
export declare function Transactional<T extends object>(options?: TransactionalOptions<T>): MethodDecorator;
|
|
14
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { RequestContext } from '../utils/RequestContext.js';
|
|
2
|
-
import { resolveContextProvider } from '../utils/resolveContextProvider.js';
|
|
3
|
-
import { TransactionContext } from '../utils/TransactionContext.js';
|
|
4
|
-
/**
|
|
5
|
-
* This decorator wraps the method with `em.transactional()`, so you can provide `TransactionOptions` just like with `em.transactional()`.
|
|
6
|
-
* The difference is that you can specify the context in which the transaction begins by providing `context` option,
|
|
7
|
-
* and if omitted, the transaction will begin in the current context implicitly.
|
|
8
|
-
* It works on async functions and can be nested with `em.transactional()`.
|
|
9
|
-
*/
|
|
10
|
-
export function Transactional(options = {}) {
|
|
11
|
-
return function (target, propertyKey, descriptor) {
|
|
12
|
-
const originalMethod = descriptor.value;
|
|
13
|
-
if (originalMethod.constructor.name !== 'AsyncFunction') {
|
|
14
|
-
throw new Error('@Transactional() should be use with async functions');
|
|
15
|
-
}
|
|
16
|
-
descriptor.value = async function (...args) {
|
|
17
|
-
const { context, contextName, ...txOptions } = options;
|
|
18
|
-
const em = (await resolveContextProvider(this, context))
|
|
19
|
-
|| TransactionContext.getEntityManager(contextName)
|
|
20
|
-
|| RequestContext.getEntityManager(contextName);
|
|
21
|
-
if (!em) {
|
|
22
|
-
throw new Error(`@Transactional() decorator can only be applied to methods of classes with \`orm: MikroORM\` property, \`em: EntityManager\` property, or with a callback parameter like \`@Transactional(() => orm)\` that returns one of those types. The parameter will contain a reference to current \`this\`. Returning an EntityRepository from it is also supported.`);
|
|
23
|
-
}
|
|
24
|
-
return em.transactional(() => originalMethod.apply(this, args), txOptions);
|
|
25
|
-
};
|
|
26
|
-
return descriptor;
|
|
27
|
-
};
|
|
28
|
-
}
|
package/decorators/hooks.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare function BeforeCreate(): (target: any, method: string) => void;
|
|
2
|
-
export declare function AfterCreate(): (target: any, method: string) => void;
|
|
3
|
-
export declare function BeforeUpdate(): (target: any, method: string) => void;
|
|
4
|
-
export declare function AfterUpdate(): (target: any, method: string) => void;
|
|
5
|
-
export declare function BeforeUpsert(): (target: any, method: string) => void;
|
|
6
|
-
export declare function AfterUpsert(): (target: any, method: string) => void;
|
|
7
|
-
export declare function OnInit(): (target: any, method: string) => void;
|
|
8
|
-
export declare function OnLoad(): (target: any, method: string) => void;
|
|
9
|
-
/**
|
|
10
|
-
* Called before deleting entity, but only when providing initialized entity to EM#remove()
|
|
11
|
-
*/
|
|
12
|
-
export declare function BeforeDelete(): (target: any, method: string) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Called after deleting entity, but only when providing initialized entity to EM#remove()
|
|
15
|
-
*/
|
|
16
|
-
export declare function AfterDelete(): (target: any, method: string) => void;
|
package/decorators/hooks.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { MetadataStorage } from '../metadata/MetadataStorage.js';
|
|
2
|
-
import { EventType } from '../enums.js';
|
|
3
|
-
function hook(type) {
|
|
4
|
-
return function (target, method) {
|
|
5
|
-
const meta = MetadataStorage.getMetadataFromDecorator(target.constructor);
|
|
6
|
-
if (!meta.hooks[type]) {
|
|
7
|
-
meta.hooks[type] = [];
|
|
8
|
-
}
|
|
9
|
-
meta.hooks[type].push(method);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export function BeforeCreate() {
|
|
13
|
-
return hook(EventType.beforeCreate);
|
|
14
|
-
}
|
|
15
|
-
export function AfterCreate() {
|
|
16
|
-
return hook(EventType.afterCreate);
|
|
17
|
-
}
|
|
18
|
-
export function BeforeUpdate() {
|
|
19
|
-
return hook(EventType.beforeUpdate);
|
|
20
|
-
}
|
|
21
|
-
export function AfterUpdate() {
|
|
22
|
-
return hook(EventType.afterUpdate);
|
|
23
|
-
}
|
|
24
|
-
export function BeforeUpsert() {
|
|
25
|
-
return hook(EventType.beforeUpsert);
|
|
26
|
-
}
|
|
27
|
-
export function AfterUpsert() {
|
|
28
|
-
return hook(EventType.afterUpsert);
|
|
29
|
-
}
|
|
30
|
-
export function OnInit() {
|
|
31
|
-
return hook(EventType.onInit);
|
|
32
|
-
}
|
|
33
|
-
export function OnLoad() {
|
|
34
|
-
return hook(EventType.onLoad);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Called before deleting entity, but only when providing initialized entity to EM#remove()
|
|
38
|
-
*/
|
|
39
|
-
export function BeforeDelete() {
|
|
40
|
-
return hook(EventType.beforeDelete);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Called after deleting entity, but only when providing initialized entity to EM#remove()
|
|
44
|
-
*/
|
|
45
|
-
export function AfterDelete() {
|
|
46
|
-
return hook(EventType.afterDelete);
|
|
47
|
-
}
|
package/decorators/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './PrimaryKey.js';
|
|
2
|
-
export * from './Entity.js';
|
|
3
|
-
export * from './OneToOne.js';
|
|
4
|
-
export * from './ManyToOne.js';
|
|
5
|
-
export * from './ManyToMany.js';
|
|
6
|
-
export { OneToMany, OneToManyOptions } from './OneToMany.js';
|
|
7
|
-
export * from './Property.js';
|
|
8
|
-
export * from './Check.js';
|
|
9
|
-
export * from './Enum.js';
|
|
10
|
-
export * from './Formula.js';
|
|
11
|
-
export * from './Indexed.js';
|
|
12
|
-
export * from './Embeddable.js';
|
|
13
|
-
export * from './Embedded.js';
|
|
14
|
-
export * from './Filter.js';
|
|
15
|
-
export * from './CreateRequestContext.js';
|
|
16
|
-
export * from './hooks.js';
|
|
17
|
-
export * from './Transactional.js';
|
package/decorators/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './PrimaryKey.js';
|
|
2
|
-
export * from './Entity.js';
|
|
3
|
-
export * from './OneToOne.js';
|
|
4
|
-
export * from './ManyToOne.js';
|
|
5
|
-
export * from './ManyToMany.js';
|
|
6
|
-
export { OneToMany } from './OneToMany.js';
|
|
7
|
-
export * from './Property.js';
|
|
8
|
-
export * from './Check.js';
|
|
9
|
-
export * from './Enum.js';
|
|
10
|
-
export * from './Formula.js';
|
|
11
|
-
export * from './Indexed.js';
|
|
12
|
-
export * from './Embeddable.js';
|
|
13
|
-
export * from './Embedded.js';
|
|
14
|
-
export * from './Filter.js';
|
|
15
|
-
export * from './CreateRequestContext.js';
|
|
16
|
-
export * from './hooks.js';
|
|
17
|
-
export * from './Transactional.js';
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { inspect } from 'node:util';
|
|
2
|
-
import type { EntityDTO, EntityProperty, IPrimaryKey, Primary } from '../typings.js';
|
|
3
|
-
import { Reference } from './Reference.js';
|
|
4
|
-
export declare class ArrayCollection<T extends object, O extends object> {
|
|
5
|
-
readonly owner: O;
|
|
6
|
-
protected readonly items: Set<T>;
|
|
7
|
-
protected initialized: boolean;
|
|
8
|
-
protected dirty: boolean;
|
|
9
|
-
protected partial: boolean;
|
|
10
|
-
protected snapshot: T[] | undefined;
|
|
11
|
-
protected _count?: number;
|
|
12
|
-
private _property?;
|
|
13
|
-
constructor(owner: O, items?: T[]);
|
|
14
|
-
loadCount(): Promise<number>;
|
|
15
|
-
getItems(): T[];
|
|
16
|
-
toArray<TT extends T>(): EntityDTO<TT>[];
|
|
17
|
-
toJSON(): EntityDTO<T>[];
|
|
18
|
-
getIdentifiers<U extends IPrimaryKey = Primary<T> & IPrimaryKey>(field?: string | string[]): U[];
|
|
19
|
-
add(entity: T | Reference<T> | Iterable<T | Reference<T>>, ...entities: (T | Reference<T>)[]): void;
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
addWithoutPropagation(entity: T): void;
|
|
24
|
-
set(items: Iterable<T | Reference<T>>): void;
|
|
25
|
-
private compare;
|
|
26
|
-
/**
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
hydrate(items: T[], forcePropagate?: boolean, partial?: boolean): void;
|
|
30
|
-
/**
|
|
31
|
-
* Remove specified item(s) from the collection. Note that removing item from collection does not necessarily imply deleting the target entity,
|
|
32
|
-
* it means we are disconnecting the relation - removing items from collection, not removing entities from database - `Collection.remove()`
|
|
33
|
-
* 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`,
|
|
34
|
-
* which tells the ORM we don't want orphaned entities to exist, so we know those should be removed.
|
|
35
|
-
*/
|
|
36
|
-
remove(entity: T | Reference<T> | Iterable<T | Reference<T>>, ...entities: (T | Reference<T>)[]): void;
|
|
37
|
-
/**
|
|
38
|
-
* Remove all items from the collection. Note that removing items from collection does not necessarily imply deleting the target entity,
|
|
39
|
-
* it means we are disconnecting the relation - removing items from collection, not removing entities from database - `Collection.remove()`
|
|
40
|
-
* 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`,
|
|
41
|
-
* which tells the ORM we don't want orphaned entities to exist, so we know those should be removed.
|
|
42
|
-
*/
|
|
43
|
-
removeAll(): void;
|
|
44
|
-
/**
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
|
-
removeWithoutPropagation(entity: T): void;
|
|
48
|
-
contains(item: T | Reference<T>, check?: boolean): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Extracts a slice of the collection items starting at position start to end (exclusive) of the collection.
|
|
51
|
-
* If end is null it returns all elements from start to the end of the collection.
|
|
52
|
-
*/
|
|
53
|
-
slice(start?: number, end?: number): T[];
|
|
54
|
-
/**
|
|
55
|
-
* Tests for the existence of an element that satisfies the given predicate.
|
|
56
|
-
*/
|
|
57
|
-
exists(cb: (item: T) => boolean): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Returns the first element of this collection that satisfies the predicate.
|
|
60
|
-
*/
|
|
61
|
-
find(cb: (item: T, index: number) => boolean): T | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Extracts a subset of the collection items.
|
|
64
|
-
*/
|
|
65
|
-
filter(cb: (item: T, index: number) => boolean): T[];
|
|
66
|
-
/**
|
|
67
|
-
* Maps the collection items based on your provided mapper function.
|
|
68
|
-
*/
|
|
69
|
-
map<R>(mapper: (item: T, index: number) => R): R[];
|
|
70
|
-
/**
|
|
71
|
-
* Maps the collection items based on your provided mapper function to a single object.
|
|
72
|
-
*/
|
|
73
|
-
reduce<R>(cb: (obj: R, item: T, index: number) => R, initial?: R): R;
|
|
74
|
-
/**
|
|
75
|
-
* Maps the collection items to a dictionary, indexed by the key you specify.
|
|
76
|
-
* If there are more items with the same key, only the first one will be present.
|
|
77
|
-
*/
|
|
78
|
-
indexBy<K1 extends keyof T, K2 extends keyof T = never>(key: K1): Record<T[K1] & PropertyKey, T>;
|
|
79
|
-
/**
|
|
80
|
-
* Maps the collection items to a dictionary, indexed by the key you specify.
|
|
81
|
-
* If there are more items with the same key, only the first one will be present.
|
|
82
|
-
*/
|
|
83
|
-
indexBy<K1 extends keyof T, K2 extends keyof T = never>(key: K1, valueKey: K2): Record<T[K1] & PropertyKey, T[K2]>;
|
|
84
|
-
count(): number;
|
|
85
|
-
isInitialized(fully?: boolean): boolean;
|
|
86
|
-
isDirty(): boolean;
|
|
87
|
-
isPartial(): boolean;
|
|
88
|
-
isEmpty(): boolean;
|
|
89
|
-
setDirty(dirty?: boolean): void;
|
|
90
|
-
get length(): number;
|
|
91
|
-
[Symbol.iterator](): IterableIterator<T>;
|
|
92
|
-
/**
|
|
93
|
-
* @internal
|
|
94
|
-
*/
|
|
95
|
-
takeSnapshot(forcePropagate?: boolean): void;
|
|
96
|
-
/**
|
|
97
|
-
* @internal
|
|
98
|
-
*/
|
|
99
|
-
getSnapshot(): T[] | undefined;
|
|
100
|
-
/**
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
get property(): EntityProperty;
|
|
104
|
-
/**
|
|
105
|
-
* @internal
|
|
106
|
-
*/
|
|
107
|
-
set property(prop: EntityProperty);
|
|
108
|
-
protected propagate(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
109
|
-
protected propagateToInverseSide(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
110
|
-
protected propagateToOwningSide(item: T, method: 'add' | 'remove' | 'takeSnapshot'): void;
|
|
111
|
-
protected shouldPropagateToCollection(collection: ArrayCollection<O, T>, method: 'add' | 'remove' | 'takeSnapshot'): boolean;
|
|
112
|
-
protected incrementCount(value: number): void;
|
|
113
|
-
/** @ignore */
|
|
114
|
-
[inspect.custom](depth?: number): string;
|
|
115
|
-
}
|
|
116
|
-
export interface ArrayCollection<T, O> {
|
|
117
|
-
[k: number]: T;
|
|
118
|
-
}
|