Database

JavaScript
const db = services.db({
  driver: "sqlite", // or "postgres"
  connection: "./.woml/app.sqlite"
});

Configuration accepts exactly driver and connection. Never point SQLite at WOML's own runtime-state database. PostgreSQL connections should normally come from a secret.

Methods:

JavaScript
await db.query({ text, values? }, options?);
await db.execute({ text, values? }, options?);
await db.read({ table, columns?, where?, orderBy?, limit? }, options?);
await db.insert({ table, values }, options?);
await db.update({ table, values, where }, options?);
await db.delete({ table, where }, options?);
await db.transaction({ operations }, options?);

SQLite uses ? parameters; PostgreSQL uses $1, $2, and so on. Never interpolate untrusted values into SQL text. update and delete helpers require non-empty where. An intentional bulk write uses explicit SQL.

Reads return { rows, rowCount }. Mutations return { rowsAffected, lastInsertId }; PostgreSQL returns lastInsertId: null. Transactions contain 1–100 query/execute/CRUD operations, run on one connection, and commit only if every operation succeeds. Nested transactions and NoSQL/document drivers are not available.

Limits include 256 KiB SQL, 10,000 result rows, 256 columns, 100 transaction operations, 1 MiB capability input, and 4 MiB capability result data.