Function handlers for CRUD operations.
To use these handlers, you need to import them first and call them with the appropriate parameters.
- Source
Methods
(async, static) addHandler(opts) → {Promise.<string>}
Handler for rendering the add view of a model.
To use this handler, you must import it first and call it with the necessary parameters. For example:
const { importModule } = this.app.bajo
const addHandler = await importModule('waibuDb:/lib/crud/add-handler.js')
const result = await addHandler.call(this, { model: 'YourModelName', req, reply })
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts | object | Options object Properties
|
- Source
Renders the add view
- Type:
- Promise.<string>
(async, static) allHandler(opts) → {Promise.<any>}
Handler for routing to the appropriate CRUD action based on the provided options.
To use this handler, you must import it first and call it with the necessary parameters. For example:
const { importModule } = this.app.bajo
const allHandler = await importModule('waibuDb:/lib/crud/all-handler.js')
const result = await allHandler.call(this, { model: 'YourModelName', action: 'list', req, reply })
For more information on the available actions, see THandlerMap.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts | object | Options object Properties
|
- Source
- See
Result of the handler
- Type:
- Promise.<any>
(async, static) deleteHandler(opts) → {Promise.<void>}
Handler for deleting records of a model.
To use this handler, you must import it first and call it with the necessary parameters. For example:
const { importModule } = this.app.bajo
const deleteHandler = await importModule('waibuDb:/lib/crud/delete-handler.js')
await deleteHandler.call(this, { model: 'YourModelName', req, reply })
| Name | Type | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts | object | Options object Properties
|
Redirects to the list view
- Type:
- Promise.<void>
(async, static) detailsHandler(opts) → {Promise.<string>}
Handler for rendering the details view of a model.
To use this handler, you must import it first and call it with the necessary parameters. For example:
const { importModule } = this.app.bajo
const detailsHandler = await importModule('waibuDb:/lib/crud/details-handler.js')
const result = await detailsHandler.call(this, { model: 'YourModelName', req, reply })
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts | object | Options object Properties
|
Renders the details view
- Type:
- Promise.<string>
(async, static) editHandler(opts) → {Promise.<string>}
Handler for rendering the edit view of a model.
To use this handler, you must import it first and call it with the necessary parameters. For example:
const { importModule } = this.app.bajo
const editHandler = await importModule('waibuDb:/lib/crud/edit-handler.js')
const result = await editHandler.call(this, { model: 'YourModelName', req, reply })
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts | object | Options object Properties
|
- Source
Renders the edit view
- Type:
- Promise.<string>
(async, static) exportHandler(opts) → {Promise.<void>}
Handler for rendering the export view of a model.
To use this handler, you must import it first and call it with the necessary parameters. For example:
const { importModule } = this.app.bajo
const exportHandler = await importModule('waibuDb:/lib/crud/export-handler.js')
await exportHandler.call(this, { model: 'YourModelName', req, reply })
| Name | Type | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts | object | Options object Properties
|
Redirect to the list view
- Type:
- Promise.<void>
(async, static) listHandler(opts) → {Promise.<string>}
Handle the list view for a given model, rendering the appropriate template with the retrieved data.
To use this handler, you must import it first and call it with the necessary parameters. For example:
const { importModule } = this.app.bajo
const listHandler = await importModule('waibuDb:/lib/crud/list-handler.js')
const result = await listHandler.call(this, { model: 'YourModelName', req, reply })
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts | object | Options object Properties
|
- Source
Renders the list view
- Type:
- Promise.<string>
Type Definitions
THandlerMap
Map of CRUD action names to their corresponding handler functions.
- Object
| Name | Type | Description |
|---|---|---|
add | function | Handler for the addHandler action |
delete | function | Handler for the deleteHandler action |
details | function | Handler for the detailsHandler action |
edit | function | Handler for the editHandler action |
export | function | Handler for the exportHandler action |
list | function | Handler for the listHandler action |
- Source