Transactions
Unless you are programming :const
forms, you will need to manipulate tables and state in order to say anything useful.
In relic, you manipulate your database with transact
.
transact
is a function that accepts a database and a set of 'transaction ops', returning a new database with the ops applied.
A key idea with relic is that you can only manipulate tables, and you try to keep data in tables to a minimum, rederiving everything else with queries. materialization
enables high performance in the face of this.
Ops
You basic operations mirror the SQL ones, see the linked docs for more info.
:insert
:update
:delete
:delete-exact
:insert-ignore
:insert-or-replace
:insert-or-merge
:insert-or-update
:replace-all
- terse insert
Additional support
- A seq of ops is a valid op, this can sometimes save some boilerplate.
- A function from db -> op is a valid op, you can use this for gnarly dependent writes where pure data doesn't cut it.
See also change tracking, constraints.