Skip to content

Type Alias: CollectionOptions<T> ​

CollectionOptions<T> = object

Defined in: src/types.ts:122

Options of an ActiveCollection.

Type Parameters ​

T ​

T = any

Properties ​

coerce? ​

optional coerce?: boolean

Defined in: src/types.ts:138

Turn plain objects into model instances (Model.createLazy). true by default; false accepts instances only.


compare? ​

optional compare?: (a, b) => number

Defined in: src/types.ts:134

Keep the collection sorted by a custom comparator (takes precedence over sortBy).

Parameters ​

a ​

T

b ​

T

Returns ​

number


order? ​

optional order?: "asc" | "desc"

Defined in: src/types.ts:136

Sort direction, asc by default.


sortBy? ​

optional sortBy?: KeyOf<T>

Defined in: src/types.ts:127

Keep the collection sorted by this key: a field name or a (item) => key function. null/undefined keys sort last.


unique? ​

optional unique?: KeyOf<T>

Defined in: src/types.ts:132

No two items may share this key (a field name or a (item) => key); null/undefined keys are exempt. Checked when items come in, and it enables getByKey() / hasKey().