Skip to content

Capabilities

Each capability lists the API that provides it and the MPA rules that define it. The same list is in docs/mpa.json for tools.

CapabilityWhat it doesAPIRules
typed-viewsDeclare the shape of nested data with Rust structs deriving View#[derive(View)]
#[view(table, key)]
MPA-CORE-1, MPA-VIEW-1
batched-loadingLoad a view with one batched query per relationship, never one per rowmabat::loadMPA-PLAN-1
multiple-databasesPostgreSQL, MySQL 8+ and SQLite, chosen by features and by the connectionfeatures: postgres, mysql, sqlite
#[view(databases)]
MPA-DB-1, MPA-DB-2
embedded-valuesStructs stored in columns of the containing view, generic or not#[view(embedded)]
#[view(embed(prefix))]
mabat::GenericColumn
MPA-VIEW-3, MPA-VIEW-4, MPA-VIEW-7
enums-with-dataRust enums with data, stored in columns or in a table per variant, decoded strictly#[view(tag, strategy, lenient)]
#[view(tag_value)]
MPA-SUM-1, MPA-SUM-2, MPA-SUM-3, MPA-SUM-4
json-columnsColumns decoded and written as JSON with serde#[view(json)]MPA-VIEW-6
to-one-referencesReferences to other views by foreign key, owned, boxed, shared or into a graph#[view(to_one(fk))]
Box<T>
MPA-VIEW-8
collectionsTo-many collections, ordered, placed by index, or as maps#[view(child(fk, order_by, index, key))]MPA-VIEW-9, MPA-VIEW-10
many-to-manyCollections through a link table#[view(child(through, target))]MPA-VIEW-9
recursive-viewsTrees and chains of parents by depth-limited levels or one WITH RECURSIVE query#[view(child(depth))]
#[view(child(recursive = "cte"))]
#[view(to_one(depth))]
#[view(to_one(recursive = "cte"))]
MPA-PLAN-4, MPA-LOAD-12, MPA-VIEW-8
shared-valuesArc values decoded once per entity and sharedArc<T>MPA-LOAD-13
graphsCyclic data as a Graph of entities with typed referencesRef<T>
Load::graph
Graph
MPA-LOAD-14
filters-and-pagingFilters, ordering, paging and counting of the root rowsmabat::filter::col
Load::filter
Load::order_by
Load::limit
Load::offset
Load::count
MPA-LOAD-4, MPA-LOAD-5, MPA-LOAD-6
nested-argumentsFilter, order and page the elements of a collection per parent, in one queryLoad::nested
Nested
MPA-LOAD-9, MPA-LOAD-10
streamingLoad many values a batch at a time, as a stream, holding one batch in memoryLoad::stream
Load::json_stream
Load::batch_size
MPA-LOAD-15, MPA-LOAD-16, MPA-LOAD-17, MPA-LOAD-18
concurrent-loadsRun the queries of each level concurrently on a pool, optionally in one snapshotPooled::snapshot
Pooled::read_committed
MPA-LOAD-11
sql-overridesReplace any query of a view with tuned SQL from a file, checked at startupMabat::builder
overrides_dir
overrides_sql
-- mabat: query <name>
MPA-OVR-1, MPA-OVR-2, MPA-OVR-3, MPA-OVR-4, MPA-OVR-5
shadow-modeRun an override next to the generated query and log differencesshadow
Mabat::shadow_stats
MPA-OVR-6
override-reloadReload override files without restartingMabat::reloadMPA-OVR-7
schema-snapshotsA snapshot of the database’s schema, its drift, and views checked against it without a databasemabat schema
mabat::schema::snapshot
mabat check --snapshot
Manifest::check_snapshot
mabat_check::build
MPA-SCH-1, MPA-SCH-2, MPA-SCH-3, MPA-SCH-4, MPA-SCH-5, MPA-SCH-6, MPA-SCH-7
dba-toolingA manifest of the views and the mabat command line tool: check, explain, scaffoldBuilder::manifest
mabat check
mabat explain
mabat scaffold
MPA-OVR-8
report-queriesReports: root SQL with named parameters and computed fieldsLoad::sql
Load::bind
#[view(computed)]
MPA-LOAD-19, MPA-VIEW-13, MPA-OVR-3
tracingtracing spans for each operation, query and statement, with names, rows and timestracing
RUST_LOG=mabat=debug
MPA-DB-6
json-loadingLoad views as JSON, whole or a selection of their fieldsLoad::json
Load::select
Selection::parse
Load::graph_json
MPA-JSON-1, MPA-JSON-3, MPA-JSON-4, MPA-JSON-5, MPA-JSON-7
graphqlA GraphQL schema generated from views, each root field one loadmabat_graphql::schemaMPA-GQL-1, MPA-GQL-2, MPA-GQL-3, MPA-GQL-4
save-aggregatesSave a value and everything it owns, creating or replacing rows by keymabat::saveMPA-WRITE-1, MPA-WRITE-3, MPA-WRITE-4, MPA-WRITE-5, MPA-WRITE-6
save-changesSave only what changed between two values of an aggregatemabat::save_changesMPA-WRITE-8
optimistic-lockingVersion columns that make stale writes fail#[view(version)]
Error::Conflict
MPA-WRITE-9, MPA-WRITE-10
save-manySave many values with statements per table and level, not per rowmabat::save_allMPA-WRITE-19
save-graphsSave every entity of a graph, ordered by its references, cycles includedmabat::save_graph
Graph::new
Graph::insert
MPA-WRITE-14, MPA-WRITE-15, MPA-WRITE-16, MPA-WRITE-17, MPA-WRITE-18
save-graph-changesSave only the entities of a graph that were inserted or handed out by get_mutmabat::save_graph_changes
Graph::is_changed
MPA-WRITE-20
generated-keysKeys generated by the database on insert, written back into the value#[view(generated)]
mabat::save
MPA-WRITE-13, MPA-WRITE-10
delete-aggregatesDelete a value and everything it ownsmabat::deleteMPA-WRITE-7
  • MPA-NOT-3 A unit of work that collects writes and flushes them later (MPA-WRITE-1).
  • MPA-NOT-4 Lazy loading: everything a view declares is loaded by the load, or selected (section 8).
  • MPA-NOT-5 Writes through overrides, and override SQL for writes.
  • MPA-NOT-6 Filtering by columns of embedded structs in filter, nested or GraphQL where.
  • MPA-NOT-7 Arguments on map collections in GraphQL, and GraphQL mutations.
  • MPA-NOT-8 Pipelining queries on one connection.
  • MPA-NOT-9 Schema generation or migrations: views describe existing tables.