Insert Bulk: Insert multiple values in a single query.
Select: Retrieve multiple rows from the result set.
First: Return the first row of the result or an error if no row exists.
First Or Null: Return the first row of the result or null if no row exists.
Update: Update a row and return the result.
Delete: Delete a row and return the result.
Query – The raw MySQL query to be executed.
Arguments – A list of values required by your query. For example, if you have a query like:
SELECT id, name FROM users WHERE id = ?
You would pass the parameter list as [1] or ["$userIdParam"] if literal arguments are enabled.
Literal Arguments – Enables dynamic creation of a literal list, where the values can be variables.
Affected Rows – Optionally enabled to return the number of affected rows from the query, if applicable.
Model – Specifies the type of data returned by the query. For a single row, use a primitive type. For multiple rows, define a struct model.
Field Mapper – A list of strings that map returned columns from the query to the specified model. For example, with the query:
SELECT id, name FROM users WHERE id = ?
You would define a struct with Id and Name fields, and use a mapper like ["Id", "Name"] to map the results to a User model.
Expected Result Set – Allocates a specific size to hold the query result.
Database – The name of the database dependency registered globally for use across your backend stack. If not provided, it defaults to MySqlDb, but you can specify a custom database name.
Cache Dependency – Allows caching of the database instance when the function is called for the first time, based on a specified caching policy.
Ensure that your server hook connects to the database once and registers it as MySqlDb or any custom name to ensure consistent access across your API.