Skip to main content

Storable

@webda/models


Interface: Storable<T, PrimaryKeyProperties>

Defined in: packages/models/src/storable.ts:57

A Storable object is an object that can be stored in a database or anywhere else and can be retrieved later

It has a primary key, a toJSON method and an Events object

Extends​

Type Parameters​

T​

T = any

PrimaryKeyProperties​

PrimaryKeyProperties extends keyof T = any

Properties​

[WEBDA_DIRTY]?​

optional [WEBDA_DIRTY]?: Set<string>

Defined in: packages/models/src/storable.ts:73

Properties that are dirty and need to be saved


[WEBDA_EVENTS]?​

optional [WEBDA_EVENTS]?: any

Defined in: packages/models/src/storable.ts:47

Inherited from​

Eventable.[WEBDA_EVENTS]


[WEBDA_PLURAL]?​

optional [WEBDA_PLURAL]?: string

Defined in: packages/models/src/storable.ts:69

Define the plural for your model


[WEBDA_PRIMARY_KEY_SEPARATOR]?​

optional [WEBDA_PRIMARY_KEY_SEPARATOR]?: string

Defined in: packages/models/src/storable.ts:65

Define the separator to use when concatenating primary key fields (for UUID generation)


[WEBDA_PRIMARY_KEY]​

[WEBDA_PRIMARY_KEY]: readonly PrimaryKeyProperties[]

Defined in: packages/models/src/storable.ts:61

Define the primary key for your model

Methods​

getPrimaryKey()​

getPrimaryKey(): IsUnion<PrimaryKeyProperties> extends true ? Pick<T, PrimaryKeyProperties> : T[PrimaryKeyProperties]

Defined in: packages/models/src/storable.ts:77

Return the primary key

Returns​

IsUnion<PrimaryKeyProperties> extends true ? Pick<T, PrimaryKeyProperties> : T[PrimaryKeyProperties]


getUUID()​

getUUID(): string

Defined in: packages/models/src/storable.ts:81

Return the string version of the primary key

Returns​

string


load()​

load(params): this

Defined in: packages/models/src/storable.ts:85

Load the serialized version of itself

Parameters​

params​

any

Returns​

this