Loading...
Loading...
Generate and modify SurrealQL queries to interact with SurrealDB databases. This includes creating and retrieving records, designing and managing schemas, establishing and querying graph relationships, performing live (real-time) queries, and leveraging all unique SurrealQL features for advanced database workflows. Use this skill whenever users need to write, adapt, or troubleshoot SurrealQL statements.
npx skill4agent add surrealdb/agent-skills surrealql.surql| Statement | Purpose |
|---|---|
| SELECT | Query records, traverse graphs, aggregate data |
| CREATE | Create new records (errors if record exists) |
| INSERT | Insert one or more records or graph edges; supports |
| UPDATE | Update existing records (no-op if record doesn't exist) |
| UPSERT | Insert a record, or update it if it already exists |
| DELETE | Delete records or graph edges |
| RELATE | Create graph edges between records |
| LIVE SELECT | Stream real-time changes to a table |
| KILL | Cancel an active LIVE SELECT query |
| LET | Assign a value to a parameter |
| RETURN | Return a value from a block or function |
| Statement | Purpose |
|---|---|
| DEFINE NAMESPACE | Define a namespace |
| DEFINE DATABASE | Define a database |
| DEFINE TABLE | Define a table (schemafull, schemaless, as view) |
| DEFINE FIELD | Define a field with type, default, assertion |
| DEFINE INDEX | Define an index (unique, search, vector) |
| DEFINE EVENT | Define event triggers on a table |
| DEFINE FUNCTION | Define a custom function |
| DEFINE ANALYZER | Define a search analyzer |
| DEFINE ACCESS | Define authentication access methods (Bearer, JWT, Record) |
| DEFINE API | Define an API endpoint |
| DEFINE BUCKET | Define a storage bucket |
| DEFINE CONFIG | Define a configuration |
| DEFINE MODULE | Define a Surrealism extension module |
| DEFINE PARAM | Define a global parameter |
| DEFINE SEQUENCE | Define an auto-incrementing sequence |
| DEFINE USER | Define a system user |
| ALTER | Alter an existing resource definition |
| REMOVE | Remove any defined resource |
| REBUILD | Rebuild an index |
| ACCESS | Manage access grants |
| USE | Switch to a different namespace or database |
| INFO | Inspect definitions for a resource |
| SHOW | View changefeed for a table or database |
| Statement | Purpose |
|---|---|
| BEGIN / COMMIT | Begin and commit a manual transaction |
| CANCEL | Cancel a transaction |
| IF / ELSE | Conditional execution |
| FOR | Iterate over values |
| BREAK | Exit a FOR loop early |
| CONTINUE | Skip to next iteration in a FOR loop |
| THROW | Cancel execution and return an error |
| SLEEP | Pause execution for a duration |
surreal version# Validate a single file:
surreal validate query.surql
# Validate glob pattern of files:
surreal validate queries/*.surql
# Validate from stdin (available since SurrealDB v3.1.0):
echo "SELECT * FROM person WHERE age > 18" | surreal validate --stdinsurqlfmt.surql# Format a file and print to stdout:
npx @surrealdb/surql-fmt query.surql
# Format files in-place:
npx @surrealdb/surql-fmt --write migrations/*.surql
# Check if files are already formatted (exits with code 1 if not):
npx @surrealdb/surql-fmt --check src/**/*.surql
# Format from stdin:
echo "SELECT * FROM person WHERE age>18" | npx @surrealdb/surql-fmt --stdin