Skip to content

Database

Luna Park ships a SQL database inside the editor. No server, no setup: you create tables, store rows, and query them from the graph.

pglite

The DB is a pglite instance (Postgres compiled to WebAssembly). All standard Postgres SQL works: types, constraints, joins, subqueries, CTEs.

Tables

A table holds rows typed by columns. The Database panel lets you:

  • create a table and define its columns (name, type, constraints);
  • add, edit, or delete rows manually;
  • inspect the contents in real time.

The id, created_at, and updated_at columns are added automatically to every table.

Database panel showing a table with its columns

Querying the database

Database nodes are used inside a route's graph (see Routes), not directly in a frontend component's graph. The route wraps the query and exposes it to the interface.

Specialized nodes

Luna Park provides one node per common SQL operation. Configuration is visual (table, parameters, filters), and the SQL is generated behind the scenes.

CategoryNodes
ReadDB Find, DB Find by Id, DB Group By, DB Join
WriteDB Insert, DB Update
DeleteDB Delete, DB Delete by Id

Parameters plug into the input anchors: an id coming from a variable, a filter value coming from an input, etc.

DB Find node configured on a table, with its parameters and output anchor

Build a query

For more precise queries, Luna Park provides nodes that chain together: each node represents a SQL operation and exposes a Query output that the next one can consume.

The starting point is always DB From, which selects the table. You then plug in the nodes you need:

NodeRole
DB FromSelects the source table
DB WhereFilters rows based on one or more conditions
DB Where ConditionDefines a condition (field, operator, target value)
DB OrderSorts the results
DB Group ByGroups rows by value
DB JoinJoins another table
DB AggregateComputes an aggregation (COUNT, SUM, AVG...)
DB Create QueryCombines multiple conditions with a logical operator (AND, OR, NOT)
DB Query SelectExecutes the query and returns the results

For example, to fetch users under 30: a DB From points to the table, a DB Where Condition defines age < 30, a DB Where receives the query and the condition, and a DB Query Select runs the whole thing.

Graph with DB From, DB Where Condition, DB Where, and DB Query Select chained together

Query preview

To see the SQL that actually runs, select the DB Query Select node and click Preview in its config.

Preparing the articles table

To follow the guided example on the Routes page, create an articles table:

  1. Open the Database panel.
  2. Create an articles table with a title column (text).
  3. Insert a few test rows.
articles table with its columns and a few example rows

The rest (exposing these articles through a route and rendering them in the interface) is covered on the Routes page.