IAdminForthDataSourceConnector
Extended by
Properties
client
client:
any
supportsCompositePrimaryKey?
optionalsupportsCompositePrimaryKey?:boolean
Set to true if connector is able to work with resources which have several columns marked as
AdminForthResourceColumn.primaryKey (composite primary key).
Such connector must build WHERE clause from pkValues argument of
IAdminForthDataSourceConnector.updateRecordOriginalValues and
IAdminForthDataSourceConnector.deleteRecord instead of using getPrimaryKey().
Methods
createRecordOriginalValues()
createRecordOriginalValues(
__namedParameters):Promise<string>
Used to create record in database. Should return value of primary key column of created record.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | { record: any; resource: AdminForthResource; } |
__namedParameters.record | any |
__namedParameters.resource | AdminForthResource |
Returns
Promise<string>
deleteRecord()
deleteRecord(
__namedParameters):Promise<boolean>
Used to delete record in database. pkValues is map of primary key column name to its value, use it to build WHERE clause (it supports both single and composite primary keys).
Parameters
| Parameter | Type |
|---|---|
__namedParameters | { pkValues?: Record<string, any>; recordId: any; resource: AdminForthResource; } |
__namedParameters.pkValues? | Record<string, any> |
__namedParameters.recordId | any |
__namedParameters.resource | AdminForthResource |
Returns
Promise<boolean>
discoverFields()
discoverFields(
resource,config):Promise<{[key:string]:AdminForthResourceColumn; }>
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: // min/max are used inside getMinMaxForColumns from base connector
- 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 | - |
config | AdminForthConfig | - |
Returns
Promise<{[key: string]: AdminForthResourceColumn; }>
getAggregateWithOriginalTypes()?
optionalgetAggregateWithOriginalTypes(__namedParameters):Promise<object[]>
Optional. Used to perform aggregation queries on a resource table. Returns rows with aliased aggregate values and optional group key.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | { aggregations: {[alias: string]: IAggregationRule; }; filters: IAdminForthAndOrFilter; groupBy?: IGroupByRule | IGroupByRule[]; resource: AdminForthResource; } |
__namedParameters.aggregations | {[alias: string]: IAggregationRule; } |
__namedParameters.filters | IAdminForthAndOrFilter |
__namedParameters.groupBy? | IGroupByRule | IGroupByRule[] |
__namedParameters.resource | AdminForthResource |
Returns
Promise<object[]>
getAllColumnsInTable()
getAllColumnsInTable(
tableName):Promise<object[]>
Function to get all columns in table.