AdminForthResourceInput
Extends
Omit
<AdminForthResourceInputCommon
,"columns"
|"hooks"
|"options"
>
Properties
columns
columns:
AdminForthResourceColumn
[]
dataSource
dataSource:
string
ID of datasource which will be used to fetch data from.
Inherited from
Omit.dataSource
dataSourceColumns?
optional
dataSourceColumns:AdminForthResourceColumn
[]
hooks?
optional
hooks: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?
optional
create:object
create.afterSave?
optional
afterSave:AfterSaveFunction
|AfterSaveFunction
[]
Typical use-cases:
- Initiate some trigger after record saved to database (e.g sync to another datasource)
create.beforeSave?
optional
beforeSave:BeforeSaveFunction
|BeforeSaveFunction
[]
Typical use-cases:
- Validate record before saving to database and interrupt execution if validation failed (
allowedActions.create
should 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?
optional
delete:object
delete.afterSave?
optional
afterSave:BeforeSaveFunction
|BeforeSaveFunction
[]
Typical use-cases:
- Initiate some trigger after record deleted from database (e.g sync to another datasource)
delete.beforeSave?
optional
beforeSave:BeforeSaveFunction
|BeforeSaveFunction
[]
Typical use-cases:
- Validate that record can be deleted and interrupt execution if validation failed (
allowedActions.delete
should be preferred in most cases)
edit?
optional
edit:object
edit.afterSave?
optional
afterSave:AfterSaveFunction
|AfterSaveFunction
[]
Typical use-cases:
- Same as hooks.create.afterSave but for edit page
edit.beforeSave?
optional
beforeSave:BeforeSaveFunction
|BeforeSaveFunction
[]
Typical use-cases:
- Same as hooks.create.beforeSave but for edit page
list?
optional
list:object
list.afterDatasourceResponse?
optional
afterDatasourceResponse: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?
optional
beforeDatasourceRequest: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?
optional
show:object
show.afterDatasourceResponse?
optional
afterDatasourceResponse: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
backendOnly
you can cleanup sensitive fields here - Attach additional data to record before returning to frontend
show.beforeDatasourceRequest?
optional
beforeDatasourceRequest:BeforeDataSourceRequestFunction
|BeforeDataSourceRequestFunction
[]
Typical use-cases:
- request additional data from database before returning to frontend for soft-join
label?
optional
label:string
Label for resource which will be displayed in the admin panel. By default it equals to table name in database.
Inherited from
Omit.label
options?
optional
options:ResourceOptionsInput
plugins?
optional
plugins:IAdminForthPlugin
[]
Array of plugins which will be used to modify resource configuration.
recordLabel()?
optional
recordLabel: (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
Omit.recordLabel
resourceId?
optional
resourceId: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
Omit.resourceId
table
table:
string
Table name in database which will be used to fetch data from. Might be case sensitive.
Inherited from
Omit.table