Skip to main content
Version: 8.0

Model class

Level: intermediate

The sdk.Model class lets you access the data source.

Pass the name of the data source entity to the public create() method to create a Model class entity.

Example that creates a Model class entity
const someModel = await sdk.Model.create('SomeEntity');

Methods

load(loadConfig?: JsonObject)

Retrieves the data.

Parameters
{JsonObject} loadConfig

Configuration object.

A configuration object is a key-value collection. View the item collection structure in the example below:

Item configuration object
loadConfig?: {
attributes?: string[];
parameters?: DataSourceParameters;
options?: DataSourceLoadOptions;
}
Item properties

{string[]} attributes

The index of attributes to retrieve.

{DataSourceParameters} parameters

An array of query filters.

{DataSourceLoadOptions} options

Additional properties required to set up pagination and sorting.

insert(dto: JsonObject)

Adds the data.

Parameters

{JsonObject} dto

JSON object that contains column names as keys and column values as key values.

update(dto: JsonObject, parameters: DataSourceParameters)

Updates the data.

Parameters

{JsonObject} dto

JSON object that contains column names as keys and column values as key values.

{DataSourceParameters} parameters

An array of query filters.

copy(primaryColumnValue: string | JsonObject, data: JsonObject = {})

Retrieves the record in copy mode. Clonable attributes are loaded. The next time the insert() method is called, the new record is saved and the clonable attribute data is copied from the original record.

Parameters

{string | JsonObject} primaryColumnValue

The primary record key.

{JsonObject} data

JSON object that contains column names as keys and column values as key values. The default value is an empty object.

delete(parameters: DataSourceParameters)

Deletes the data.

Parameters

{DataSourceParameters} parameters

An array of query filters.

canSave(params: DataSourceCanExecuteOperationPayload)

Checks for user permissions to save the model. 

Parameters

{DataSourceCanExecuteOperationPayload}  params

An array of query filters.

canDelete(params: DataSourceCanExecuteOperationPayload)

Checks for user permissions to delete the model.

Parameters

{DataSourceCanExecuteOperationPayload} params

An array of query filters.