IAdminForthDataSourceConnector
Extended by
Methods
createRecordOriginalValues()
createRecordOriginalValues(
__namedParameters
):Promise
<void
>
Used to create record in database.
Parameters
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.record | any |
__namedParameters.resource | AdminForthResource |
Returns
Promise
<void
>
deleteRecord()
deleteRecord(
__namedParameters
):Promise
<boolean
>
Used to delete record in database.
Parameters
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.recordId | any |
__namedParameters.resource | AdminForthResource |
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
Parameter | Type | Description |
---|---|---|
resource | AdminForthResource |
Returns
Promise
<object
>
getCount()
getCount(
__namedParameters
):Promise
<number
>
Used to get count of records in database.
Parameters
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.filters | IAdminForthFilter [] |
__namedParameters.resource | AdminForthResource |
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
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.filters | IAdminForthFilter [] |
__namedParameters.limit | number |
__namedParameters.offset | number |
__namedParameters.resource | AdminForthResource |
__namedParameters.sort | IAdminForthSort [] |
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
Parameter | Type | Description |
---|---|---|
field | AdminForthResourceColumn | |
value | any |
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
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.columns | AdminForthResourceColumn [] |
__namedParameters.resource | AdminForthResource |
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
Parameter | Type |
---|---|
resource | AdminForthResource |
recordId | string |
Returns
Promise
<any
>
setFieldValue()
setFieldValue(
field
,value
):any
Used to transform record before saving to database. Should perform operation inverse to IAdminForthDataSourceConnector.getFieldValue
Parameters
Parameter | Type | Description |
---|---|---|
field | AdminForthResourceColumn | |
value | any |
Returns
any
updateRecordOriginalValues()
updateRecordOriginalValues(
__namedParameters
):Promise
<void
>
Update record in database. newValues might have not all fields in record, but only changed ones. recordId is value of field which is marked as AdminForthResourceColumn.primaryKey
Parameters
Parameter | Type |
---|---|
__namedParameters | object |
__namedParameters.newValues | any |
__namedParameters.recordId | string |
__namedParameters.resource | AdminForthResource |
Returns
Promise
<void
>