Skip to main content
Version: 5.3

LoadedCollection <T>

Hierarchy

Index

Properties

$

$: Collection<T, unknown>

readonlyowner

owner: Partial<unknown> & { [EntityRepositoryType]?: unknown; [PrimaryKeyType]?: unknown; __helper?: IWrappedEntityInternal<unknown, never, string>; __meta?: EntityMetadata<unknown>; __platform?: Platform }

Accessors

length

  • get length(): number
  • Returns number

Methods

[custom]

  • [custom](depth: number): string
  • Parameters

    • depth: number

    Returns string

[iterator]

  • [iterator](): IterableIterator<T>
  • Returns IterableIterator<T>

add

  • Parameters

    Returns void

contains

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

    Returns boolean

count

  • count(): number
  • Returns number

get

getIdentifiers

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

    Parameters

    • optionalfield: string

    Returns U[]

getItems

  • getItems(check?: boolean): T[]
  • Returns the items (the collection must be initialized)


    Parameters

    • optionalcheck: boolean

    Returns T[]

init

isDirty

  • isDirty(): boolean
  • Returns boolean

isInitialized

  • isInitialized(fully?: boolean): boolean
  • Parameters

    • fully: boolean = false

    Returns boolean

loadCount

  • loadCount(refresh?: boolean): Promise<number>
  • 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

    • refresh: boolean = false

    Returns Promise<number>

loadItems

  • Initializes the collection and returns the items


    Type parameters

    • P: string = never

    Parameters

    Returns Promise<Loaded<T, P>[]>

matching

  • Type parameters

    • P: string = never

    Parameters

    Returns Promise<Loaded<T, P>[]>

populated

  • populated(populated?: boolean): void
  • Parameters

    • populated: boolean = true

    Returns void

remove

  • remove(...items: (T | Reference<T> | (item: T) => boolean)[]): void
  • Remove specified item(s) from the collection. Note that removing item from collection does necessarily imply deleting the target entity, it means we are disconnecting the relation - removing items from collection, not removing entities from database - Collection.remove() 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, which tells the ORM we don’t want orphaned entities to exist, so we know those should be removed.


    Parameters

    • rest...items: (T | Reference<T> | (item: T) => boolean)[]

    Returns void

removeAll

  • removeAll(): void
  • Remove all items from the collection. Note that removing items from collection does necessarily imply deleting the target entity, it means we are disconnecting the relation - removing items from collection, not removing entities from database - Collection.remove() 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, which tells the ORM we don’t want orphaned entities to exist, so we know those should be removed.


    Returns void

set

  • Parameters

    Returns void

setDirty

  • setDirty(dirty?: boolean): void
  • Parameters

    • dirty: boolean = true

    Returns void

shouldPopulate

  • shouldPopulate(): boolean
  • Returns boolean

toArray

  • Returns EntityDTO<T>[]

toJSON

  • Returns EntityDTO<T>[]