Version: 4.2

Class: Collection<T, O>

Type parameters#

NameDefault
T-
Ounknown

Hierarchy#

Indexable#

▪ [k: number]: T

Constructors#

constructor#

+ new Collection(owner: O, items?: T[], initialized?: boolean): Collection

Overrides ArrayCollection.constructor

Defined in packages/core/src/entity/Collection.ts:13

Parameters:#

NameTypeDefault value
ownerO-
items?T[]-
initializedbooleantrue

Returns: Collection

Properties#

_firstItem#

Protected Optional _firstItem: T

Inherited from ArrayCollection._firstItem

Defined in packages/core/src/entity/ArrayCollection.ts:12


_lazyInitialized#

Private _lazyInitialized: boolean = false

Defined in packages/core/src/entity/Collection.ts:13


_populated#

Private _populated: boolean = false

Defined in packages/core/src/entity/Collection.ts:12


dirty#

Private dirty: boolean = false

Defined in packages/core/src/entity/Collection.ts:11


initialized#

Protected initialized: boolean = true

Inherited from ArrayCollection.initialized

Defined in packages/core/src/entity/ArrayCollection.ts:11


items#

Protected Readonly items: Set<T> = new Set<T>()

Inherited from ArrayCollection.items

Defined in packages/core/src/entity/ArrayCollection.ts:10


owner#

Readonly owner: O & AnyEntity<O>

Inherited from ArrayCollection.owner

Defined in packages/core/src/entity/ArrayCollection.ts:15


snapshot#

Private snapshot: T[] | undefined = []

Defined in packages/core/src/entity/Collection.ts:10

Accessors#

length#

• get length(): number

Inherited from ArrayCollection.length

Defined in packages/core/src/entity/ArrayCollection.ts:117

Returns: number


property#

• get property(): EntityProperty<T>

Inherited from ArrayCollection.property

Defined in packages/core/src/entity/ArrayCollection.ts:130

internal

Returns: EntityProperty<T>

Methods#

[Symbol.iterator]#

[Symbol.iterator](): IterableIterator<T>

Inherited from ArrayCollection.[Symbol.iterator]

Defined in packages/core/src/entity/ArrayCollection.ts:121

Returns: IterableIterator<T>


add#

add(...items: (T | Reference<T>)[]): void

Overrides ArrayCollection.add

Defined in packages/core/src/entity/Collection.ts:69

Parameters:#

NameType
...items(T | Reference<T>)[]

Returns: void


cancelOrphanRemoval#

PrivatecancelOrphanRemoval(items: T[]): void

Defined in packages/core/src/entity/Collection.ts:272

Parameters:#

NameType
itemsT[]

Returns: void


checkInitialized#

PrivatecheckInitialized(): void

Defined in packages/core/src/entity/Collection.ts:257

Returns: void


contains#

contains(item: T | Reference<T>, check?: boolean): boolean

Overrides ArrayCollection.contains

Defined in packages/core/src/entity/Collection.ts:118

Parameters:#

NameTypeDefault value
itemT | Reference<T>-
checkbooleantrue

Returns: boolean


count#

count(): number

Overrides ArrayCollection.count

Defined in packages/core/src/entity/Collection.ts:126

Returns: number


createCondition#

PrivatecreateCondition<T>(cond?: FilterQuery<T>): FilterQuery<T>

Defined in packages/core/src/entity/Collection.ts:214

Type parameters:#

NameType
TAnyEntity<T>

Parameters:#

NameTypeDefault value
condFilterQuery<T>{}

Returns: FilterQuery<T>


createManyToManyCondition#

PrivatecreateManyToManyCondition(cond: Dictionary): void

Defined in packages/core/src/entity/Collection.ts:236

Parameters:#

NameType
condDictionary

Returns: void


createOrderBy#

PrivatecreateOrderBy(orderBy?: QueryOrderMap): QueryOrderMap

Defined in packages/core/src/entity/Collection.ts:224

Parameters:#

NameTypeDefault value
orderByQueryOrderMap{}

Returns: QueryOrderMap


getIdentifiers#

getIdentifiers<U>(field?: string): U[]

Inherited from ArrayCollection.getIdentifiers

Defined in packages/core/src/entity/ArrayCollection.ts:48

Type parameters:#

NameTypeDefault
UIPrimaryKeyPrimary\<T> & IPrimaryKey

Parameters:#

NameType
field?string

Returns: U[]


getItems#

getItems(check?: boolean): T[]

Overrides ArrayCollection.getItems

Defined in packages/core/src/entity/Collection.ts:53

Returns the items (the collection must be initialized)

Parameters:#

NameTypeDefault value
checkbooleantrue

Returns: T[]


getSnapshot#

getSnapshot(): T[]

Defined in packages/core/src/entity/Collection.ts:210

internal

Returns: T[]


hydrate#

hydrate(items: T[], validate?: boolean, takeSnapshot?: boolean): void

Overrides ArrayCollection.hydrate

Defined in packages/core/src/entity/Collection.ts:88

internal

Parameters:#

NameTypeDefault value
itemsT[]-
validatebooleanfalse
takeSnapshotbooleantrue

Returns: void


init#

init(options?: InitOptions<T>): Promise<this>

Defined in packages/core/src/entity/Collection.ts:148

Parameters:#

NameType
options?InitOptions<T>

Returns: Promise<this>

init(populate?: string[], where?: FilterQuery<T>, orderBy?: QueryOrderMap): Promise<this>

Defined in packages/core/src/entity/Collection.ts:149

Parameters:#

NameType
populate?string[]
where?FilterQuery<T>
orderBy?QueryOrderMap

Returns: Promise<this>


isDirty#

isDirty(): boolean

Defined in packages/core/src/entity/Collection.ts:140

Returns: boolean


isInitialized#

isInitialized(fully?: boolean): boolean

Inherited from ArrayCollection.isInitialized

Defined in packages/core/src/entity/ArrayCollection.ts:109

Parameters:#

NameTypeDefault value
fullybooleanfalse

Returns: boolean


loadItems#

loadItems(): Promise<T[]>

Defined in packages/core/src/entity/Collection.ts:42

Initializes the collection and returns the items

Returns: Promise<T[]>


modify#

Privatemodify(method: "add" | "remove", items: T[]): void

Defined in packages/core/src/entity/Collection.ts:247

Parameters:#

NameType
method"add" | "remove"
itemsT[]

Returns: void


populated#

populated(populated?: boolean): void

Defined in packages/core/src/entity/Collection.ts:135

Parameters:#

NameTypeDefault value
populatedbooleantrue

Returns: void


propagate#

Protectedpropagate(item: T, method: "add" | "remove"): void

Inherited from ArrayCollection.propagate

Defined in packages/core/src/entity/ArrayCollection.ts:140

Parameters:#

NameType
itemT
method"add" | "remove"

Returns: void


propagateToInverseSide#

ProtectedpropagateToInverseSide(item: T, method: "add" | "remove"): void

Inherited from ArrayCollection.propagateToInverseSide

Defined in packages/core/src/entity/ArrayCollection.ts:148

Parameters:#

NameType
itemT
method"add" | "remove"

Returns: void


propagateToOwningSide#

ProtectedpropagateToOwningSide(item: T, method: "add" | "remove"): void

Inherited from ArrayCollection.propagateToOwningSide

Defined in packages/core/src/entity/ArrayCollection.ts:156

Parameters:#

NameType
itemT
method"add" | "remove"

Returns: void


remove#

remove(...items: (T | Reference<T>)[]): void

Overrides ArrayCollection.remove

Defined in packages/core/src/entity/Collection.ts:106

Parameters:#

NameType
...items(T | Reference<T>)[]

Returns: void


removeAll#

removeAll(): void

Inherited from ArrayCollection.removeAll

Defined in packages/core/src/entity/ArrayCollection.ts:96

Returns: void


reorderItems#

PrivatereorderItems(items: T[], order: T[]): void

Defined in packages/core/src/entity/Collection.ts:266

re-orders items after searching with $in operator

Parameters:#

NameType
itemsT[]
orderT[]

Returns: void


set#

set(items: (T | Reference<T>)[]): void

Overrides ArrayCollection.set

Defined in packages/core/src/entity/Collection.ts:76

Parameters:#

NameType
items(T | Reference<T>)[]

Returns: void


setDirty#

setDirty(dirty?: boolean): void

Defined in packages/core/src/entity/Collection.ts:144

Parameters:#

NameTypeDefault value
dirtybooleantrue

Returns: void


shouldPopulate#

shouldPopulate(): boolean

Defined in packages/core/src/entity/Collection.ts:131

Returns: boolean


shouldPropagateToCollection#

ProtectedshouldPropagateToCollection(collection: ArrayCollection<O, T>, method: "add" | "remove"): boolean

Inherited from ArrayCollection.shouldPropagateToCollection

Defined in packages/core/src/entity/ArrayCollection.ts:166

Parameters:#

NameType
collectionArrayCollection<O, T>
method"add" | "remove"

Returns: boolean


takeSnapshot#

takeSnapshot(): void

Defined in packages/core/src/entity/Collection.ts:202

internal

Returns: void


toArray#

toArray(): Dictionary[]

Inherited from ArrayCollection.toArray

Defined in packages/core/src/entity/ArrayCollection.ts:33

Returns: Dictionary[]


toJSON#

toJSON(): Dictionary[]

Overrides ArrayCollection.toJSON

Defined in packages/core/src/entity/Collection.ts:61

Returns: Dictionary[]


validateItemType#

PrivatevalidateItemType(item: T | Primary<T> | EntityData<T>): void

Defined in packages/core/src/entity/Collection.ts:284

Parameters:#

NameType
itemT | Primary<T> | EntityData<T>

Returns: void


validateModification#

PrivatevalidateModification(items: T[]): void

Defined in packages/core/src/entity/Collection.ts:290

Parameters:#

NameType
itemsT[]

Returns: void


create#

Staticcreate<T, O>(owner: O, prop: keyof O, items: undefined | T[], initialized: boolean): Collection<T, O>

Defined in packages/core/src/entity/Collection.ts:28

Creates new Collection instance, assigns it to the owning entity and sets the items to it (propagating them to their inverse sides)

Type parameters:#

NameDefault
T-
Oany

Parameters:#

NameType
ownerO
propkeyof O
itemsundefined | T[]
initializedboolean

Returns: Collection<T, O>

Last updated on by Renovate Bot