AdminForthResourceInput
Extends
Omit<NonNullable<AdminForthResourceInputCommon>,"columns"|"hooks"|"options">
Properties
columns
columns:
AdminForthResourceColumnInput[]
dataSource
dataSource:
string
ID of datasource which will be used to fetch data from.
Inherited from
AdminForthResourceInputCommon.dataSource
dataSourceColumns?
optionaldataSourceColumns:AdminForthResourceColumn[]
hooks?
optionalhooks:object
Hooks allow you to change the data on different stages of resource lifecycle. Hooks are functions which will be called on backend side (only backend side).
create?
optionalcreate:object
create.afterSave?
optionalafterSave:AfterCreateSaveFunction|AfterCreateSaveFunction[]
Typical use-cases:
- Initiate some trigger after record saved to database (e.g sync to another datasource)
create.beforeSave?
optionalbeforeSave:BeforeCreateSaveFunction|BeforeCreateSaveFunction[]
Typical use-cases:
- Validate record before saving to database and interrupt execution if validation failed (
allowedActions.createshould be preferred in most cases) - fill-in adminUser as creator of record
- Attach additional data to record before saving to database (mostly fillOnCreate should be used instead)
delete?
optionaldelete:object
delete.afterSave?
optionalafterSave:BeforeDeleteSaveFunction|BeforeDeleteSaveFunction[]
Typical use-cases:
- Initiate some trigger after record deleted from database (e.g sync to another datasource)
delete.beforeSave?
optionalbeforeSave:BeforeDeleteSaveFunction|BeforeDeleteSaveFunction[]
Typical use-cases:
- Validate that record can be deleted and interrupt execution if validation failed (
allowedActions.deleteshould be preferred in most cases)
edit?
optionaledit:object
edit.afterSave?
optionalafterSave:AfterEditSaveFunction|AfterEditSaveFunction[]
Typical use-cases:
- Same as hooks.create.afterSave but for edit page
edit.beforeSave?
optionalbeforeSave:BeforeEditSaveFunction|BeforeEditSaveFunction[]
Typical use-cases:
- Same as hooks.create.beforeSave but for edit page
list?
optionallist:object
list.afterDatasourceResponse?
optionalafterDatasourceResponse:AfterDataSourceResponseFunction|AfterDataSourceResponseFunction[]
Typical use-cases:
- Same as hooks.show.afterDatasourceResponse but applied for all records returned from database for showing in list view, e.g. add new field to each record in list view
list.beforeDatasourceRequest?
optionalbeforeDatasourceRequest:BeforeDataSourceRequestFunction|BeforeDataSourceRequestFunction[]
Typical use-cases:
- add additional filters in addition to what user selected before fetching data from database.
- same as hooks.show.beforeDatasourceRequest
show?
optionalshow:object
show.afterDatasourceResponse?
optionalafterDatasourceResponse:AfterDataSourceResponseFunction|AfterDataSourceResponseFunction[]
Typical use-cases:
- Transform value for some field for record returned from database before returning to frontend (minimize, sanitize, etc)
- If some-why you can't use
backendOnlyyou can cleanup sensitive fields here - Attach additional data to record before returning to frontend
show.beforeDatasourceRequest?
optionalbeforeDatasourceRequest:BeforeDataSourceRequestFunction|BeforeDataSourceRequestFunction[]
Typical use-cases:
- request additional data from database before returning to frontend for soft-join
label?
optionallabel:string
Label for resource which will be displayed in the admin panel. By default it equals to table name in database.
Inherited from
AdminForthResourceInputCommon.label
options?
optionaloptions:ResourceOptionsInput
plugins?
optionalplugins:IAdminForthPlugin[]
Array of plugins which will be used to modify resource configuration.
recordLabel()?
optionalrecordLabel: (item) =>string
Hook which allow you to modify record label
Example:
recordLabel: (record) => `${record.name} - ${record.id}`,
Parameters
| Parameter | Type |
|---|---|
item | any |
Returns
string
Inherited from
AdminForthResourceInputCommon.recordLabel
resourceId?
optionalresourceId:string
Unique identifier of resource. By default it equals to table name in database. If you wish you can explicitly set it to any string. We added to support cases when 2 datasources have tables with the same name.
Inherited from
AdminForthResourceInputCommon.resourceId
table
table:
string
Table name in database which will be used to fetch data from. Might be case sensitive.