Documentation
    Preparing search index...

    Class CollectionProperty

    A basic relational property type representing a collection of BaseObject instances. This core class manages the in-memory array representation. For dynamic querying, see the backend CollectionProperty.

    const permissions = new CollectionProperty({
    name: 'permissions',
    instanceOf: Permission
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _allows: string[] = []
    _defaultValue: any
    _events: { [key: string]: Function } = {}
    _hasChanged: boolean
    _htmlType: PropertyHTMLType = 'off'
    _id: string
    _instanceOf: typeof BaseObject
    _mandatory: boolean = false
    _name: string
    _parent: DataObjectClass<any> | undefined
    _parentKey: string
    _protected: boolean = false
    _value: any[] | DataObjectClass<any>[] | ObjectUri[] | undefined = undefined
    EVENT_ONCHANGE: string = 'onChange'

    Event name triggered when the property value changes.

    EVENT_ONDELETE: string = 'onDelete'

    Event name triggered when the property is deleted.

    TYPE: string = 'collection'

    The string literal type identifier for this property.

    Accessors

    • get allows(): string[]

      Returns string[]

    • get hasChanged(): boolean

      Returns boolean

    • set hasChanged(val: boolean): void

      Parameters

      • val: boolean

      Returns void

    • get htmlType(): PropertyHTMLType

      Returns PropertyHTMLType

    • set htmlType(type: PropertyHTMLType): void

      Parameters

      Returns void

    • get mandatory(): boolean

      Returns boolean

    • get name(): string

      Returns string

    • get protected(): boolean

      Returns boolean

    Methods

    • Parameters

      • value: boolean | undefined

      Returns value is true | undefined

    • Applies an anonymous function to each item in the collection. Can execute either on the internal collection value or an external array. Supporting both synchronous and asynchronous callback functions.

      Parameters

      • fn: (item: any) => any

        The anonymous callback function to apply to each item.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns any[] | Promise<any[]>

      The results of the function applications (or a Promise resolving to the results if async).

    • Calculates the average of the numeric values of a property across items in the collection. Can aggregate either the internal collection value or an external array.

      Parameters

      • property: string

        The name of the property to average.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns number | Promise<number>

      The average of all numeric values, or 0 if empty.

    • Creates a deep clone of the current property instance, preserving its prototype chain.

      Returns any

      A new independent instance of the property.

    • Returns the count of items in the collection, optionally filtered by a predicate callback. Can aggregate either the internal collection value or an external array.

      Parameters

      • Optionalpredicate: (item: any) => boolean

        An optional filter callback to run on each item.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns number | Promise<number>

      The count of matching items.

    • Retrieves all distinct values of a property across the collection items. Can aggregate either the internal collection value or an external array.

      Parameters

      • property: string

        The name of the property.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns any[] | Promise<any[]>

      An array of unique property values.

    • Groups the collection items by the values of a specific property. Can aggregate either the internal collection value or an external array.

      Parameters

      • property: string

        The name of the property to group by.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns Record<string, any[]> | Promise<Record<string, any[]>>

      A dictionary object where keys are the property values and values are arrays of matching items.

    • Returns the maximum value of a numeric property across the collection items. Can aggregate either the internal collection value or an external array.

      Parameters

      • property: string

        The name of the property.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns number | Promise<number | undefined> | undefined

      The maximum numeric value found, or undefined if no valid numbers are present.

    • Returns the minimum value of a numeric property across the collection items. Can aggregate either the internal collection value or an external array.

      Parameters

      • property: string

        The name of the property.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns number | Promise<number | undefined> | undefined

      The minimum numeric value found, or undefined if no valid numbers are present.

    • Plucks a specific property from each item in the collection. Can aggregate either the internal collection value or an external array.

      Parameters

      • property: string

        The name of the property to extract.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns any[] | Promise<any[]>

      An array containing the extracted property values.

    • Assigns an array of related objects or URIs to the collection.

      Parameters

      • value: any[]

        The array of elements to assign.

      • setChanged: boolean = true

        Whether to mark the property as modified.

      Returns CollectionProperty

      The property instance for chaining.

    • Sums the numeric values of a property across items in the collection. Can aggregate either the internal collection value or an external array.

      Parameters

      • property: string

        The name of the property to sum.

      • items: any[] = ...

        Optional external items array. Defaults to the internal collection array.

      Returns number | Promise<number>

      The sum of all numeric values.

    • Retrieves the current value of the property, or its default value if currently undefined.

      Parameters

      • transform: any = undefined

        An optional transformation function applied to the value before returning it.

      Returns any

      The raw or transformed property value.