Database: database

database provides the database storage, and named queries and mutations, including defquery, defmutation and defreactor. Select it for definitions that use those forms, and for each request that reads or writes data.

SettingPurpose
pathPersistent database file.
temporarytrue opens a private temporary file. Closing the database deletes it.

Give path or temporary true, not both. Without either setting, the database opens no storage. Evaluation works, and each database operation fails with no_database: queries, mutations, transact, imports, saved namespaces, reactor status, and any request with as-of (eval, sessions/open, schemas/valid? and programs/signature). Without the database plugin, there is also no storage.

Configuration

Select this plugin explicitly when opening the database:

json70 B
{
  "plugins": {
    "database": {
      "path": "app.db"
    }
  }
}

Usage

With database selected, save and export named defquery and defmutation forms in a namespace. Call them from DUST or through a generated SDK.

A host can also subscribe to an exported defquery. The subscription delivers the query's complete result, then a new result after each commit that changes a field the query reads, or the namespace that defines it. The generated Go SDK has a SubscribeTo method for each exported query, and the ABI has the queries/subscribe request. A DUST evaluation returns one value, so DUST code cannot subscribe.

A saved defreactor is a mutation that the database runs. Each later write that changes a field the reactor reads or writes runs it before the write commits, and the facts it writes share the write's transaction. When two reactors propose different values for one field, the database keeps the value with the higher priority. The defreactor section of the DUST reference describes the rounds and the failures that reject a write.

Contributions

Namespaces

NamespaceContribution
db
Functions
db/reactors

Unqualified additions

Macros