ArrayCollection <T, O>
Hierarchy
- ArrayCollection
Index
Constructors
constructor
Parameters
owner: O
optionalitems: T[]
Returns ArrayCollection<T, O>
Properties
readonlyowner
Accessors
length
Returns number
Methods
[iterator]
Returns IterableIterator<T, any, any>
add
contains
Parameters
item: T | Reference<T>
optionalcheck: boolean
Returns boolean
count
Returns number
exists
Parameters
cb: (item: T) => boolean
Returns boolean
filter
Extracts a subset of the collection items.
Parameters
cb: (item: T, index: number) => boolean
Returns T[]
find
Returns the first element of this collection that satisfies the predicate.
Parameters
cb: (item: T, index: number) => boolean
Returns undefined | T
getIdentifiers
Parameters
optionalfield: string
Returns U[]
getItems
Returns T[]
indexBy
Maps the collection items to a dictionary, indexed by the key you specify. If there are more items with the same key, only the first one will be present.
Parameters
key: K1
Returns Record<T[K1] & PropertyKey, T>
isDirty
Returns boolean
isEmpty
Returns boolean
isInitialized
Parameters
fully: boolean = false
Returns boolean
loadCount
Returns Promise<number>
map
Maps the collection items based on your provided mapper function.
Parameters
mapper: (item: T, index: number) => R
Returns R[]
reduce
Maps the collection items based on your provided mapper function to a single object.
Parameters
cb: (obj: R, item: T, index: number) => R
initial: R = ...
Returns R
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 asem.remove()
. If we want to delete the entity by removing it from collection, we need to enableorphanRemoval: true
, which tells the ORM we don't want orphaned entities to exist, so we know those should be removed.Parameters
entity: T | Reference<T> | Iterable<T | Reference<T>, any, any>
rest...entities: (T | Reference<T>)[]
Returns void
removeAll
Remove all items from the collection. Note that removing items 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 asem.remove()
. If we want to delete the entity by removing it from collection, we need to enableorphanRemoval: true
, which tells the ORM we don't want orphaned entities to exist, so we know those should be removed.Returns void
set
Parameters
items: Iterable<T | Reference<T>, any, any>
Returns void
setDirty
Parameters
dirty: boolean = true
Returns void
slice
Extracts a slice of the collection items starting at position start to end (exclusive) of the collection. If end is null it returns all elements from start to the end of the collection.
Parameters
start: number = 0
optionalend: number
Returns T[]
toArray
Returns EntityDTO<TT>[]
toJSON
Returns EntityDTO<T>[]
Tests for the existence of an element that satisfies the given predicate.