Skip to main content

IAdminForthDataSourceConnector

Extended by

Methods

createRecordOriginalValues()

createRecordOriginalValues(__namedParameters): Promise<void>

Used to create record in database.

Parameters

ParameterType
__namedParametersobject
__namedParameters.recordany
__namedParameters.resourceAdminForthResource

Returns

Promise<void>


deleteRecord()

deleteRecord(__namedParameters): Promise<boolean>

Used to delete record in database.

Parameters

ParameterType
__namedParametersobject
__namedParameters.recordIdany
__namedParameters.resourceAdminForthResource

Returns

Promise<boolean>


discoverFields()

discoverFields(resource): Promise<object>

Function should go over all columns of table defined in resource.table and try to guess data and constraints for each columns. Type should be saved to:

  • AdminForthResourceColumn.type Constraints:
  • AdminForthResourceColumn.required
  • AdminForthResourceColumn.primaryKey For string fields:
  • AdminForthResourceColumn.maxLength For numbers:
  • AdminForthResourceColumn.min
  • AdminForthResourceColumn.max
  • AdminForthResourceColumn.minValue, AdminForthResourceColumn.maxValue, AdminForthResourceColumn.enum, AdminForthResourceColumn.foreignResource, AdminForthResourceColumn.sortable, AdminForthResourceColumn.backendOnly, AdminForthResourceColumn.masked, AdminForthResourceColumn.virtual, AdminForthResourceColumn.components, AdminForthResourceColumn.allowMinMaxQuery, AdminForthResourceColumn.editingNote, AdminForthResourceColumn.showIn, AdminForthResourceColumn.isUnique, AdminForthResourceColumn.validation) Also you can additionally save original column type to AdminForthResourceColumn._underlineType. This might be later used in IAdminForthDataSourceConnector.getFieldValue and IAdminForthDataSourceConnector.setFieldValue methods.

Parameters

ParameterTypeDescription
resourceAdminForthResource

Returns

Promise<object>


getCount()

getCount(__namedParameters): Promise<number>

Used to get count of records in database.

Parameters

ParameterType
__namedParametersobject
__namedParameters.filtersIAdminForthFilter[]
__namedParameters.resourceAdminForthResource

Returns

Promise<number>


getDataWithOriginalTypes()

getDataWithOriginalTypes(__namedParameters): Promise<any[]>

Used to fetch data from database. This method is reused both to list records and show one record (by passing limit 1 and offset 0) .

Fields are returned from db "as is" then AdminForthBaseConnector.getData will transform each field using IAdminForthDataSourceConnector.getFieldValue

Parameters

ParameterType
__namedParametersobject
__namedParameters.filtersIAdminForthFilter[]
__namedParameters.limitnumber
__namedParameters.offsetnumber
__namedParameters.resourceAdminForthResource
__namedParameters.sortIAdminForthSort[]

Returns

Promise<any[]>


getFieldValue()

getFieldValue(field, value): any

Used to transform record after fetching from database. According to AdminForth convention, if AdminForthResourceColumn.type is set to AdminForthDataTypes.DATETIME then it should be transformed to ISO string.

Parameters

ParameterTypeDescription
fieldAdminForthResourceColumn
valueany

Returns

any


getMinMaxForColumnsWithOriginalTypes()

getMinMaxForColumnsWithOriginalTypes(__namedParameters): Promise<object>

Optional method which used to get min and max values for columns in resource. Called only for columns which have AdminForthResourceColumn.allowMinMaxQuery set to true.

Internally should call IAdminForthDataSourceConnector.getFieldValue for both min and max values.

Parameters

ParameterType
__namedParametersobject
__namedParameters.columnsAdminForthResourceColumn[]
__namedParameters.resourceAdminForthResource

Returns

Promise<object>


getRecordByPrimaryKeyWithOriginalTypes()

getRecordByPrimaryKeyWithOriginalTypes(resource, recordId): Promise<any>

Optional. You an redefine this function to define how one record should be fetched from database. You you will not redefine it, AdminForth will use IAdminForthDataSourceConnector.getData with limit 1 and offset 0 and filter by primary key.

Parameters

ParameterType
resourceAdminForthResource
recordIdstring

Returns

Promise<any>


setFieldValue()

setFieldValue(field, value): any

Used to transform record before saving to database. Should perform operation inverse to IAdminForthDataSourceConnector.getFieldValue

Parameters

ParameterTypeDescription
fieldAdminForthResourceColumn
valueany

Returns

any


updateRecord()

updateRecord(__namedParameters): Promise<void>

Used to update record in database. recordId is value of field which is marked as AdminForthResourceColumn.primaryKey newValues is array of fields which should be updated (might be not all fields in record, but only changed fields).

Parameters

ParameterType
__namedParametersobject
__namedParameters.newValuesany
__namedParameters.recordIdstring
__namedParameters.resourceAdminForthResource

Returns

Promise<void>