onBeforeInsert()
This hook/event is called the before creating a new record.
It can be used in the INSERT
handler.
ts
import { IHookParameter } from "axe-api";
export default async (parameters: IHookParameter) => {
// do something in here
};
IHookParameters
The following parameters can be used in the hook/event function;
Parameter | Description |
---|---|
request | Request object of Expresss |
response | Response object of Expresss |
model | Current model instance. For example; User |
database | Database connection instance. For example Knex.js |
relation | The relation definition if the route is a related route (For example api/v1/users/:userId/posts ). |
parentModel | The parent model instance if the route is a related route (For example api/v1/users/:userId/posts ). |
formData | The data has been sent by HTTP client to create or update row. |