Skip to main content

AdminForthResource

Resource describes one table or collection in database. AdminForth generates set of pages for 'list', 'show', 'edit', 'create', 'filter' operations for each resource.

Extends

Properties

columns

columns: AdminForthResourceColumn[]

Overrides

Omit.columns


dataSource

dataSource: string

ID of datasource which will be used to fetch data from.

Inherited from

Omit.dataSource


dataSourceColumns

dataSourceColumns: AdminForthResourceColumn[]

Overrides

Omit.dataSourceColumns


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[]

Typical use-cases:

  • Initiate some trigger after record saved to database (e.g sync to another datasource)

create.beforeSave?

optional beforeSave: BeforeCreateSaveFunction[]

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[]

Typical use-cases:

  • Initiate some trigger after record deleted from database (e.g sync to another datasource)

delete.beforeSave?

optional beforeSave: 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[]

Typical use-cases:

  • Same as hooks.create.afterSave but for edit page

edit.beforeSave?

optional beforeSave: BeforeSaveFunction[]

Typical use-cases:

  • Same as hooks.create.beforeSave but for edit page

list?

optional list: object

list.afterDatasourceResponse?

optional afterDatasourceResponse: 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[]

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[]

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[]

Typical use-cases:

  • request additional data from database before returning to frontend for soft-join

Overrides

Omit.hooks


label

label: string

Overrides

Omit.label


options

options: ResourceOptions


plugins?

optional plugins: IAdminForthPlugin[]

Array of plugins which will be used to modify resource configuration.

Overrides

Omit.plugins


recordLabel()

recordLabel: (record) => string

Parameters

ParameterType
recordany

Returns

string

Overrides

Omit.recordLabel


resourceId

resourceId: string

Overrides

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