Community Dashboard

Data

A service that declares a database gets its own SQLite file, migrated at deploy, and every call to it runs as one transaction.

The database

  • A program declares its database with #[program(database = "migrations")], a directory of .sql files applied in name order at deploy.
  • A deploy whose migrations do not begin with the ones already applied is refused. A migration that fails refuses the deploy, and the running version keeps serving.
  • Tables named _berm_* are reserved.

Statements

berm_lang::sql(statement, params) runs one statement, with params a JSON array bound to its ? placeholders. It answers {"columns": [..], "rows": [[..]], "read": n, "written": n}.

let found = berm_lang::sql("SELECT title FROM items WHERE id = ?", "[42]")?;
  • Every statement of one call runs in one transaction, committed when the tool returns Ok.
  • BEGIN, COMMIT and other transaction statements are refused.
  • A #[query] tool cannot write.
  • One statement answers at most 4 MiB.

Without a database

A program without a database keeps values by key with berm_lang::get and berm_lang::set.

Storage

Stored bytes count everything the service keeps: the database, its write-ahead log, its keyed values, its logs while they are kept, and its image and compiled code. See Plans.