Docs

Query Language

Liven uses a pipeline-based query language. Compose stages with | to build complex data flows from simple parts.

How It Works

Every query starts with a from("stream_name") stage that selects a stream. You then chain additional stages with the pipe operator (|) to filter, transform, aggregate, and enrich the data. Terminal dot-methods like .insert() or .listen()execute the query.

from("events") // Select stream
| filter(amount > 100) // Filter records
| group(status, count()) // Group & aggregate
| sort(timestamp, desc) // Sort results
| limit(50) // Cap at 50 records

Query Types

There are three classes of operations:

  • Read queries — pipeline stages that filter, transform, and analyze existing data. They return matching records.
  • Write queries — terminal dot-methods that insert, upsert, update, or delete data. They return a status record.
  • Subscriptions — the .listen() suffix turns any read query into a real-time stream.

Quick Examples

Insert a record

from("users").insert("user_1", {name: "Alice", role: "admin"})

Query with a filter

from("orders") | filter(amount > 100 and status == "completed") | count()

Real-time subscription

from("events") | filter(type == "error") .listen()