Version: 4.3

Interface: LoadedCollection<T, P, O>

Type parameters

NameTypeDefault
TAnyEntity<T>-
P-never
O-unknown

Hierarchy

Indexable

▪ [k: number]: T

Constructors

constructor

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

Inherited from Collection.constructor

Overrides ArrayCollection.constructor

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

Parameters:

NameTypeDefault value
ownerO-
items?T[]-
initializedbooleantrue

Returns: LoadedCollection

Properties

$

$: readonly T & P[]

Defined in packages/core/src/typings.ts:382


_count

Protected Optional _count: number

Inherited from ArrayCollection._count

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


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>

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

Accessors

length

• get length(): number

Inherited from ArrayCollection.length

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

Returns: number


property

• get property(): EntityProperty<T>

Inherited from ArrayCollection.property

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

internal

Returns: EntityProperty<T>

Methods

[Symbol.iterator]

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

Inherited from ArrayCollection.[Symbol.iterator]

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

Returns: IterableIterator<T>


add

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

Inherited from Collection.add

Overrides ArrayCollection.add

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

Parameters:

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

Returns: void


contains

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

Inherited from Collection.contains

Overrides ArrayCollection.contains

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

Parameters:

NameTypeDefault value
itemT | Reference<T>-
checkbooleantrue

Returns: boolean


count

count(): number

Inherited from Collection.count

Overrides ArrayCollection.count

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

Returns: number


get

get(): readonly T & P[]

Defined in packages/core/src/typings.ts:383

Returns: readonly T & P[]


getIdentifiers

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

Inherited from ArrayCollection.getIdentifiers

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

Type parameters:

NameTypeDefault
UIPrimaryKeyPrimary\<T> & IPrimaryKey

Parameters:

NameType
field?string

Returns: U[]


getItems

getItems(check?: boolean): T[]

Inherited from Collection.getItems

Overrides ArrayCollection.getItems

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

Returns the items (the collection must be initialized)

Parameters:

NameTypeDefault value
checkbooleantrue

Returns: T[]


getSnapshot

getSnapshot(): T[]

Inherited from Collection.getSnapshot

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

internal

Returns: T[]


hydrate

hydrate(items: T[]): void

Inherited from Collection.hydrate

Overrides ArrayCollection.hydrate

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

internal

Parameters:

NameType
itemsT[]

Returns: void


incrementCount

ProtectedincrementCount(value: number): void

Inherited from ArrayCollection.incrementCount

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

Parameters:

NameType
valuenumber

Returns: void


init

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

Inherited from Collection.init

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

Parameters:

NameType
options?InitOptions<T>

Returns: Promise<this>

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

Inherited from Collection.init

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

Parameters:

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

Returns: Promise<this>


isDirty

isDirty(): boolean

Inherited from Collection.isDirty

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

Returns: boolean


isInitialized

isInitialized(fully?: boolean): boolean

Inherited from ArrayCollection.isInitialized

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

Parameters:

NameTypeDefault value
fullybooleanfalse

Returns: boolean


loadCount

loadCount(refresh?: boolean): Promise<number>

Inherited from Collection.loadCount

Overrides ArrayCollection.loadCount

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

Gets the count of collection items from database instead of counting loaded items. The value is cached, use refresh = true to force reload it.

Parameters:

NameTypeDefault value
refreshbooleanfalse

Returns: Promise<number>


loadItems

loadItems(): Promise<T[]>

Inherited from Collection.loadItems

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

Initializes the collection and returns the items

Returns: Promise<T[]>


populated

populated(populated?: boolean): void

Inherited from Collection.populated

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

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:146

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:154

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:162

Parameters:

NameType
itemT
method"add" | "remove"

Returns: void


remove

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

Inherited from Collection.remove

Overrides ArrayCollection.remove

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

Parameters:

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

Returns: void


removeAll

removeAll(): void

Inherited from ArrayCollection.removeAll

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

Returns: void


set

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

Inherited from Collection.set

Overrides ArrayCollection.set

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

Parameters:

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

Returns: void


setDirty

setDirty(dirty?: boolean): void

Inherited from Collection.setDirty

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

Parameters:

NameTypeDefault value
dirtybooleantrue

Returns: void


shouldPopulate

shouldPopulate(): boolean

Inherited from Collection.shouldPopulate

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

Returns: boolean


shouldPropagateToCollection

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

Inherited from ArrayCollection.shouldPropagateToCollection

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

Parameters:

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

Returns: boolean


takeSnapshot

takeSnapshot(): void

Inherited from Collection.takeSnapshot

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

internal

Returns: void


toArray

toArray(): Dictionary[]

Inherited from ArrayCollection.toArray

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

Returns: Dictionary[]


toJSON

toJSON(): Dictionary[]

Inherited from Collection.toJSON

Overrides ArrayCollection.toJSON

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

Returns: Dictionary[]


create

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

Inherited from Collection.create

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 Martin Adámek