The Macros service allows you to create and manage custom SQL macros that can be used in permission rules. Macros provide reusable SQL fragments that help you write more complex and dynamic permission logic.Documentation Index
Fetch the complete documentation index at: https://docs.snackbase.dev/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Most macro operations require superadmin authentication.
List Macros
Retrieve all available macros, including built-in ones:Get a Macro
Get details for a specific macro:Create a Macro
Create a new custom macro:template property uses {{parameter_name}} syntax for parameter substitution.
Update a Macro
Update an existing custom macro:Built-in macros cannot be updated.
Delete a Macro
Delete a custom macro:You cannot delete built-in macros or macros that are currently in use by permission rules.
Test a Macro
Test a macro with specific parameters:Built-in Macros
SnackBase provides several built-in macros:| Name | Description |
|---|---|
current_user | Get the ID of the currently authenticated user |
current_account | Get the ID of the current account |
user_roles | Get roles for a specific user |
group_members | Get members of a specific group |
Using Macros in Rules
Macros can be referenced in permission rules using the{{macro_name}} syntax:
Next Steps
- Permissions - Understand permission rules
- Roles Service - Manage roles and permissions
- Collection Rules - Apply rules to collections