LoadedCollection <T>
Hierarchy
- Collection<T>
- LoadedCollection
Index
Properties
$
readonlyowner
Accessors
length
Returns number
Methods
[custom]
Parameters
depth: number
Returns string
[iterator]
Returns IterableIterator<T>
add
contains
Parameters
item: T | Reference<T>
check: boolean = true
Returns boolean
count
Returns number
get
Returns Collection<T, object>
getIdentifiers
Type parameters
- U: IPrimaryKeyValue = Object
Parameters
optionalfield: string
Returns U[]
getItems
Parameters
optionalcheck: boolean
Returns T[]
init
Type parameters
- P: string = never
Parameters
options: InitOptions<T, P> = {}
Returns Promise<LoadedCollection<Loaded<T, P>>>
isDirty
Returns boolean
isInitialized
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), userefresh: true
to force reload it.Parameters
options: boolean | LoadCountOptions<T> = {}
Returns Promise<number>
loadItems
Initializes the collection and returns the items
Type parameters
- P: string = never
Parameters
optionaloptions: InitOptions<T, P>
Returns Promise<Loaded<T, P>[]>
matching
Type parameters
- P: string = never
Parameters
options: MatchingOptions<T, P>
Returns Promise<Loaded<T, P>[]>
populated
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 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> | (T | Reference<T>)[] | (item: T) => boolean
rest...entities: (T | Reference<T>)[]
Returns void
removeAll
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 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: (T | Reference<T>)[]
Returns void
setDirty
Parameters
dirty: boolean = true
Returns void
shouldPopulate
Returns boolean
toArray
Returns EntityDTO<T>[]
toJSON
Returns EntityDTO<T>[]
Returns the items (the collection must be initialized)