Opens the database at DB_PATH when first imported, creating it from schema.sql if the file doesn't exist, then applies the pending migrations and runs the startup tasks before any importer runs. Only the services import it.
f
transaction<T>(fn: () => T): T
Runs fn in a transaction, so its writes commit together, in one commit
rather than one each, and a throw rolls them all back and rethrows. A call
inside another joins the outer transaction. fn must be synchronous: an
await would commit before the rest of it runs.
v
db: DatabaseSync
Serves every query of the server, as its only connection. Its queries are synchronous, so each one blocks the event loop while it runs.
Usage
import * as mod from "api/db/connection.ts";