Skip to main content

Module sqlite

Module sqlite 

Source
Expand description

The reference SQLite store (ADR 0017 §2): Kovlet’s bookkeeping tables in a SQLite file, either its own or the app’s.

  • SqliteStore::open: its own file, with the built-in row store, so an app with no database can read rows back (space.table("todos").all()).
  • SqliteStore::shared: the app’s own connection. The bookkeeping tables live next to the app’s tables, and the core runs the app’s apply and its own commit in one transaction. SqliteStore::shared_batch is the same with one apply call per ChangeBatch instead of per Change.
  • SqliteStore::lending: for an app whose database type owns its connection (and keeps derived state on write). The app lends its connection for one transaction at a time, e.g. |f| db.with_tx(f), so app rows, derived state and Kovlet’s bookkeeping commit together.
  • Record mode: inside its own transaction, the app writes its rows and calls space.record(&tx, table, id, fields), which queues the write in the same transaction (Workplane’s pattern).

Structs§

SqliteStore
See the module docs.

Constants§

SCHEMA
The bookkeeping schema (ADR 0017 §2), plus trashed on the _deleted row.

Type Aliases§

ApplyBatchFn
Writes a whole batch into the app’s own tables, inside the core’s transaction.
ApplyFn
Writes one change into the app’s own tables, inside the core’s transaction.
LendFn
Lends the app’s connection for one transaction: begin a transaction, call f with it, commit if f returns Ok, roll back otherwise, and return f’s result. See SqliteStore::lending.