Skip to main content
Version: 5.2

ArrayCollection <T, O>

Hierarchy

Indexable

[k: number]: T

Index

Constructors

constructor

  • new ArrayCollection<T, O>(owner: O & Partial<O> & { [EntityRepositoryType]?: unknown; [PrimaryKeyType]?: unknown; __helper?: IWrappedEntityInternal<O, keyof O, string>; __meta?: EntityMetadata<O>; __platform?: Platform }, items?: T[]): ArrayCollection<T, O>
  • Type parameters

    • T
    • O

    Parameters

    • owner: O & Partial<O> & { [EntityRepositoryType]?: unknown; [PrimaryKeyType]?: unknown; __helper?: IWrappedEntityInternal<O, keyof O, string>; __meta?: EntityMetadata<O>; __platform?: Platform }
    • optionalitems: T[]

    Returns ArrayCollection<T, O>

Properties

readonlyowner

owner: O & Partial<O> & { [EntityRepositoryType]?: unknown; [PrimaryKeyType]?: unknown; __helper?: IWrappedEntityInternal<O, keyof O, string>; __meta?: EntityMetadata<O>; __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

getIdentifiers

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

    Parameters

    • optionalfield: string

    Returns U[]

getItems

  • getItems(): T[]
  • Returns T[]

isInitialized

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

    • fully: boolean = false

    Returns boolean

loadCount

  • loadCount(): Promise<number>
  • Returns Promise<number>

remove

  • 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

    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

toArray

toJSON