Query icon
Log icon
SlackIncomingWebhook icon

CRUD operations in SurrealQL: run multiple SurrealDB queries and send the query results via Slack

Orchestrate SurrealDB CRUD operations in SurrealQL with Kestra. Run queries, parse results, and post structured updates to Slack from one declarative flow.

Categories
Data

This blueprint orchestrates a full SurrealDB CRUD lifecycle in SurrealQL and pushes the final query result into Slack. It walks through creating records, deleting rows, updating fields, joining across tables with subqueries, and reading data back, then routes the result to a chat channel so the team sees the outcome without opening the database. It solves the gap between running ad hoc SurrealQL statements and getting reliable, observable, scheduled data operations with downstream notifications.

How it works

The flow runs a sequence of io.kestra.plugin.surrealdb.Query tasks against a SurrealDB instance, then logs and notifies on the final result.

  1. company inserts a company record with name = 'Kestra' and a time::now() timestamp.
  2. delete_anna removes the author:anna record so the flow is idempotent on re-run.
  3. add_author_tbl (disabled by default) shows how to create an author:anna row with nested name fields and an admin flag.
  4. fix_admin_permission runs an UPDATE that flips admin = false for the matching author.
  5. create_article_tbl inserts an article row that links to author:anna and to the company via a SELECT VALUE id subquery.
  6. query runs SELECT title FROM article with fetchType: FETCH_ONE to capture a single row into outputs.
  7. log_query_results writes {{ outputs.query.row }} via io.kestra.plugin.core.log.Log.
  8. slack posts {{ outputs.query.row.title }} to an incoming webhook using io.kestra.plugin.slack.notifications.SlackIncomingWebhook.

Shared SurrealDB connection settings (host, database, namespace, username, password) are centralized in pluginDefaults so every Query task inherits them.

What you get

  • A reusable pattern for chaining SurrealQL statements in one auditable run.
  • Centralized connection config via pluginDefaults instead of repeating credentials per task.
  • Captured query output you can reference downstream with {{ outputs.query.row }}.
  • Slack delivery of the result so the team is notified the moment data changes.
  • A safe, idempotent skeleton you can extend to real CRUD pipelines.

Who it's for

  • Data engineers wiring SurrealDB into a broader orchestration stack.
  • Backend developers automating seed, migration, or cleanup routines.
  • Platform teams who want chat notifications on database state changes.
  • Anyone evaluating SurrealDB and wanting a working Kestra reference flow.

Why orchestrate this with Kestra

SurrealDB ships a powerful query engine but no scheduler, retry layer, or notification fabric. Kestra fills that gap with declarative YAML, event and cron triggers, automatic retries, full execution history, and per-task logs and outputs. You get lineage across the entire CRUD sequence, can fan out to Slack, email, or webhooks on success or failure, and can wire the same flow to events from other systems (S3 uploads, Kafka messages, API calls) without writing glue code.

Prerequisites

  • A reachable SurrealDB instance. Defaults assume localhost, namespace test, database test, user root.
  • A Slack incoming webhook URL.
  • Network access from Kestra workers to both endpoints.

Secrets

  • SLACK_WEBHOOK: incoming webhook URL used by the slack task to post the query result.

Quick start

  1. Install or point Kestra at a SurrealDB instance and adjust pluginDefaults if you are not running locally with the root user.
  2. Create a Slack incoming webhook and store it as the SLACK_WEBHOOK secret.
  3. Optionally enable add_author_tbl (set disabled: false) on the first run to seed the author:anna record.
  4. Execute the flow from the Kestra UI and confirm the Slack channel receives the article title.
  5. Inspect outputs.query.row in the Outputs panel to see the captured SurrealDB row.

How to extend

  • Replace the hard-coded CREATE/UPDATE payloads with flow inputs to drive parameterized writes.
  • Add a Schedule or Webhook trigger to run the CRUD sequence on a cadence or on demand.
  • Branch on outputs.query.row with io.kestra.plugin.core.flow.If to alert only on specific titles or values.
  • Swap Slack for Microsoft Teams, Discord, or email by changing only the final notification task.
  • Wrap mutations in transactions or guards using additional SurrealQL statements per task.

Links

Orchestrate with Kestra
Orchestrate Slack with Kestra
Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.