Skip to main content

@webda/coreReadme | API


Class: ModelRefWithCreate<T>

Extends

Type parameters

T extends CoreModel

Constructors

new ModelRefWithCreate(uuid, model, parent)

new ModelRefWithCreate<T>(uuid, model, parent?): ModelRefWithCreate<T>

Parameters

uuid: string

model: CoreModelDefinition<T>

parent?: CoreModel

Returns

ModelRefWithCreate<T>

Inherited from

ModelRef.constructor

Source

packages/core/src/models/coremodel.ts:442

Properties

model

protected model: CoreModelDefinition<T>

Inherited from

ModelRef.model

Source

packages/core/src/models/coremodel.ts:438


parent

protected parent: CoreModel

Inherited from

ModelRef.parent

Source

packages/core/src/models/coremodel.ts:440


store

protected store: Store<T, StoreParameters, StoreEvents>

Inherited from

ModelRef.store

Source

packages/core/src/models/coremodel.ts:436


uuid

protected uuid: string

Inherited from

ModelRef.uuid

Source

packages/core/src/models/coremodel.ts:443

Methods

conditionalPatch()

conditionalPatch(updates, conditionField, condition): Promise<boolean>

Parameters

updates: Partial<T>

conditionField: any

condition: any

Returns

Promise<boolean>

Inherited from

ModelRef.conditionalPatch

Source

packages/core/src/models/coremodel.ts:528


create()

create(defaultValue, context?, withSave?): Promise<T>

Allow to create a model

Parameters

defaultValue: RawModel<T>

context?: OperationContext<any, any>

withSave?: boolean= true

Returns

Promise<T>

Source

packages/core/src/models/coremodel.ts:580


delete()

delete(): Promise<void>

Returns

Promise<void>

Inherited from

ModelRef.delete

Source

packages/core/src/models/coremodel.ts:525


deleteItemFromCollection()

deleteItemFromCollection(prop, index, itemWriteCondition, itemWriteConditionField?): Promise<ModelRefWithCreate<T>>

Parameters

prop: FilterAttributes<T, any[]>

index: number

itemWriteCondition: any

itemWriteConditionField?: string

Returns

Promise<ModelRefWithCreate<T>>

Inherited from

ModelRef.deleteItemFromCollection

Source

packages/core/src/models/coremodel.ts:467


exists()

exists(): Promise<boolean>

Returns

Promise<boolean>

Inherited from

ModelRef.exists

Source

packages/core/src/models/coremodel.ts:522


get()

get(context?): Promise<T>

Parameters

context?: OperationContext<any, any>

Returns

Promise<T>

Inherited from

ModelRef.get

Source

packages/core/src/models/coremodel.ts:451


getOrCreate()

getOrCreate(defaultValue, context?, withSave?): Promise<T>

Load a model from the known store

Parameters

defaultValue: RawModel<T>

if object not found return a default object

context?: OperationContext<any, any>

to set on the object

withSave?: boolean= true

Returns

Promise<T>

Source

packages/core/src/models/coremodel.ts:597


getUuid()

getUuid(): string

Returns

string

Inherited from

ModelRef.getUuid

Source

packages/core/src/models/coremodel.ts:464


incrementAttributes()

incrementAttributes(info): Promise<ModelRefWithCreate<T>>

Parameters

info: Object[]

Returns

Promise<ModelRefWithCreate<T>>

Inherited from

ModelRef.incrementAttributes

Source

packages/core/src/models/coremodel.ts:553


patch()

patch(updates): Promise<boolean>

Parameters

updates: Partial<T>

Returns

Promise<boolean>

Inherited from

ModelRef.patch

Source

packages/core/src/models/coremodel.ts:531


removeAttribute()

removeAttribute(attribute, itemWriteCondition?, itemWriteConditionField?): Promise<ModelRefWithCreate<T>>

Parameters

attribute: keyof T

itemWriteCondition?: any

itemWriteConditionField?: keyof T

Returns

Promise<ModelRefWithCreate<T>>

Inherited from

ModelRef.removeAttribute

Source

packages/core/src/models/coremodel.ts:538


set()

set(id): void

Parameters

id: string | T

Returns

void

Inherited from

ModelRef.set

Source

packages/core/src/models/coremodel.ts:454


setAttribute()

setAttribute(attribute, value): Promise<ModelRefWithCreate<T>>

Parameters

attribute: keyof T

value: any

Returns

Promise<ModelRefWithCreate<T>>

Inherited from

ModelRef.setAttribute

Source

packages/core/src/models/coremodel.ts:534


toJSON()

toJSON(): string

Returns

string

Inherited from

ModelRef.toJSON

Source

packages/core/src/models/coremodel.ts:461


toString()

toString(): string

Returns

string

Inherited from

ModelRef.toString

Source

packages/core/src/models/coremodel.ts:458


upsertItemToCollection()

upsertItemToCollection(prop, item, index?, itemWriteCondition?, itemWriteConditionField?): Promise<ModelRefWithCreate<T>>

Parameters

prop: FilterAttributes<T, any[]>

item: any

index?: number

itemWriteCondition?: any

itemWriteConditionField?: string

Returns

Promise<ModelRefWithCreate<T>>

Inherited from

ModelRef.upsertItemToCollection

Source

packages/core/src/models/coremodel.ts:493