Skip to main content
Version: 5.7

LoadedCollection <T>

Hierarchy

Index

Properties

$

$: Collection<T, object>

readonlyowner

owner: object

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

    • U: IPrimaryKeyValue = Object

    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

  • Gets the count of collection items from database instead of counting loaded items. The value is cached (unless you use the where option), use refresh: true to force reload it.


    Parameters

    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 specified item(s) from the collection. Note that removing item from collection does not 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

    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>[]