LoadedCollection <T>
Hierarchy
- Collection<T>
- LoadedCollection
Index
Properties
$
readonlyinheritedowner
Accessors
inheritedlength
Returns number
Methods
inherited[iterator]
Returns IterableIterator<T, any, any>
inheritedadd
inheritedcontains
Parameters
item: TT | Reference<TT>
check: boolean = true
Returns boolean
inheritedcount
Returns number
inheritedexists
Parameters
cb: (item: T) => boolean
Returns boolean
inheritedfilter
Extracts a subset of the collection items.
Parameters
cb: (item: T, index: number) => boolean
Returns T[]
inheritedfind
Returns the first element of this collection that satisfies the predicate.
Parameters
cb: (item: T, index: number) => boolean
Returns undefined | T
get
Returns Collection<T, object>
inheritedgetIdentifiers
Parameters
optionalfield: string
Returns U[]
getItems
Returns the items (the collection must be initialized)
Parameters
optionalcheck: boolean
Returns T[]
inheritedindexBy
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>
inheritedinit
Parameters
options: InitCollectionOptions<TT, P, *, never> = {}
Returns Promise<LoadedCollection<Loaded<TT, P>>>
inheritedisDirty
Returns boolean
inheritedisEmpty
Returns boolean
inheritedisInitialized
Parameters
fully: boolean = false
Returns boolean
inheritedload
Ensures the collection is loaded first (without reloading it if it already is loaded). Returns the Collection instance (itself), works the same as
Reference.load()
.Parameters
options: InitCollectionOptions<TT, P, *, never> = {}
Returns Promise<LoadedCollection<Loaded<TT, P>>>
inheritedloadCount
Gets the count of collection items from database instead of counting loaded items. The value is cached (unless you use the
where
option), userefresh: true
to force reload it.Parameters
options: boolean | LoadCountOptions<T> = {}
Returns Promise<number>
inheritedloadItems
Initializes the collection and returns the items
Parameters
optionaloptions: InitCollectionOptions<TT, P, *, never>
Returns Promise<Loaded<TT, P>[]>
inheritedmap
Maps the collection items based on your provided mapper function.
Parameters
mapper: (item: T, index: number) => R
Returns R[]
inheritedmatching
Parameters
options: MatchingOptions<T, P>
Returns Promise<Loaded<TT, P>[]>
inheritedpopulated
Parameters
populated: undefined | boolean = true
Returns void
inheritedreduce
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
inheritedremove
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: TT | Reference<TT> | Iterable<TT | Reference<TT>, any, any> | (item: TT) => boolean
rest...entities: (TT | Reference<TT>)[]
Returns void
inheritedremoveAll
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
inheritedset
Parameters
items: Iterable<T | Reference<T>, any, any>
Returns void
inheritedsetDirty
Parameters
dirty: boolean = true
Returns void
inheritedshouldPopulate
Parameters
optionalpopulated: boolean
Returns boolean
inheritedslice
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
optionalstart: number
optionalend: number
Returns T[]
inheritedtoArray
Returns EntityDTO<TT>[]
inheritedtoJSON
Returns EntityDTO<TT>[]
Tests for the existence of an element that satisfies the given predicate.