Options
All
  • Public
  • Public/Protected
  • All
Menu

Retrieves an entity instance using Generic REST API.

Type parameters

  • T

    entity type.

Hierarchy

  • DataInstanceStore

Implements

Index

Constructors

constructor

  • new DataInstanceStore<T>(mainStore: MainStore, entityName: string, viewName?: string, stringIdName?: null | string): DataInstanceStore<T>

Properties

changedItems

changedItems: IObservableArray<never> = ...
inheritdoc

Readonly entityName

entityName: string

item

item: null | (T & Partial<SerializedEntityProps> & WithId) = null

Retrieved entity instance.

lastError

lastError: null | "COMMIT_ERROR" | "LOAD_ERROR" = null
inheritdoc

status

status: DataContainerStatus = "CLEAN"
inheritdoc

stringIdName

stringIdName: null | string

Name of the ID attribute of a String ID entity. Mandatory for String ID entities, shall be omitted otherwise.

viewName

viewName: string

Name of the view used to limit the entity graph.

Methods

commit

  • commit(commitMode?: "create" | "edit"): Promise<Partial<T>>
  • Sends a request to the REST API to persist the changes made to the item.

    Parameters

    • Optional commitMode: "create" | "edit"

      see update

    Returns Promise<Partial<T>>

    a promise that resolves to the update result returned by the REST API.

getFieldValues

  • getFieldValues(properties: string[]): Partial<{[ prop in string | number | symbol]: any }>
  • Transforms the item into the format expected by Ant Design Form fields.

    Parameters

    • properties: string[]

      entity properties that should be included in the result.

    Returns Partial<{[ prop in string | number | symbol]: any }>

    entity instance transformed into the format expected by Ant Design Form fields.

load

  • load(id: string): void
  • Retrieves an entity instance using the given id and view by sending a request to the REST API.

    Parameters

    • id: string

      id of an entity instance to be retrieved.

    Returns void

setItem

  • setItem(item: null | (T & Partial<SerializedEntityProps> & WithId)): void

setItemToFormFields

  • setItemToFormFields(formFields: Partial<T>): void
  • Sets the item based on provided values of Ant Design Form fields.

    Parameters

    • formFields: Partial<T>

      a object representing the values of Ant Design Form fields.

    Returns void

update

  • update(entityPatch: Record<string, any>, commitMode?: "create" | "edit"): Promise<any>
  • Updates the item using a provided entityPatch, then sends a request to the REST API to persist the changes.

    Parameters

    • entityPatch: Record<string, any>

      a Partial representing the changes to be made.

    • Optional commitMode: "create" | "edit"

      'create' when creating a new entity or 'edit' when editing an existing one. Different REST API endpoints and HTTP methods will be used depending on whether the entity is new. IMPORTANT: If this parameter is omitted, then the entity will be considered new if it lacks the id attribute. This will produce incorrect results for String ID entities. Therefore using this parameter is mandatory for String ID entities.

    Returns Promise<any>

    a promise that resolves to the update result returned by the REST API.

Generated using TypeDoc