Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ellomas.com/llms.txt

Use this file to discover all available pages before exploring further.

Database Operations

The db step type executes PostgreSQL queries or Redis commands directly within your workflow.

PostgreSQL

Configuration

Set the connection string in workflow config:
config:
  postgres:
    dsn: postgres://user:password@localhost:5432/mydb

### Running Queries

```yaml
- name: query-users
  type: db
  query: "SELECT id, email, created_at FROM users WHERE status = 'active'"

INSERT with RETURNING

- name: create-user
  type: db
  query: |
    INSERT INTO users (name, email)
    VALUES ('Alice', 'alice@example.com')
    RETURNING id;
  extract:
    new_id: $[0].id

Extraction from Results

Query results are returned as an array of row objects:
[
  { "id": 1, "name": "Alice", "email": "alice@example.com" },
  { "id": 2, "name": "Bob", "email": "bob@example.com" }
]
Use JSONPath to extract values:
extract:
  first_name: $[0].name
  all_emails: $[*].email

Template Variables in Queries

- name: find-user
  type: db
  query: "SELECT * FROM users WHERE id = {{ user_id }}"

Assertions on Results

- name: check-user
  type: db
  query: "SELECT count(*) as cnt FROM users"
  assert:
    - ["$[0].cnt", "gt", 0]

Redis

Configuration

config:
  redis:
    addr: localhost:6379

Commands

Use the command array format:
- name: set-value
  type: db
  engine: redis
  command: ["SET", "session:1", "active"]

GET and Extract

- name: get-value
  type: db
  engine: redis
  command: ["GET", "session:1"]
  extract:
    session_status: $
  assert:
    - ["$", "eq", "active"]

Complex Commands

- name: hash-operations
  type: db
  engine: redis
  command: ["HSET", "user:42", "name", "Alice", "score", "100"]

- name: get-hash
  type: db
  engine: redis
  command: ["HGETALL", "user:42"]
  extract:
    user_data: $

Engine Shorthand

You can use flat shortcuts instead of the db: block:
# Full block
- name: query
  type: db
  db:
    engine: postgres
    query: SELECT 1

# Shorthand
- name: query
  type: db
  engine: postgres
  query: SELECT 1

# Redis shorthand
- name: cache
  type: db
  engine: redis
  command: ["SET", "key", "val"]

What’s Next?