Skip to content

Attributes

Every attribute #[derive(View)] accepts. A test fails when the derive accepts one that is not listed here.

AttributeOnSyntaxMeaningRules
tablestruct, variant#[view(table = "t")]The table of a view, or of a variantMPA-VIEW-1, MPA-SUM-3
keystruct, variant#[view(key = "c")]The key column, id by defaultMPA-VIEW-2, MPA-SUM-3
embeddedstruct#[view(embedded)]A struct stored in columns of the containing view, generic over types or notMPA-VIEW-3, MPA-VIEW-4
databasesstruct, enum#[view(databases = "postgres, mysql")]Limit the databases a view is decoded and encoded onMPA-DB-2
tagenum#[view(tag = "c")]The column naming the variantMPA-SUM-1
strategyenum#[view(strategy = "tag" | "table_per_variant")]Where the variants’ data is storedMPA-SUM-2, MPA-SUM-3
lenientenum#[view(lenient)]Allow non-NULL columns of other variantsMPA-SUM-4
tag_valuevariant#[view(tag_value = "v")]The tag of a variant, its name by defaultMPA-SUM-1
columnfield#[view(column = "c")]The column of a field, its name by defaultMPA-VIEW-5
jsonfield#[view(json)]A column decoded and written as JSONMPA-VIEW-6
versionfield#[view(version)]An integer version column for optimistic lockingMPA-WRITE-9, MPA-WRITE-10
generatedfield#[view(generated)]A key the database generates when the row is insertedMPA-WRITE-13
computedfield#[view(computed)]A value SQL computes, not a column of the tableMPA-VIEW-13
embedfield#[view(embed)]An embedded struct or enumMPA-VIEW-7
prefixfield#[view(embed(prefix = "p_"))]The column prefix of an embedded valueMPA-VIEW-7
to_onefield#[view(to_one(fk = "c"))]A reference to another viewMPA-VIEW-8
childfield#[view(child(fk = "c"))]A to-many collectionMPA-VIEW-9, MPA-VIEW-10
fkto_one, childfk = "c"The foreign key columnMPA-VIEW-8, MPA-VIEW-9
order_bychildorder_by = "a, b desc"The order of the elementsMPA-VIEW-9
throughchildthrough = "link"The link table of a many-to-many collectionMPA-VIEW-9
targetchildtarget = "c"The link table column referencing the elementMPA-VIEW-9
indexchildindex = "c"The column placing the elements of a VecMPA-VIEW-9
keychildkey = "c"The column keying the elements of a mapMPA-VIEW-9
depthchild, to_onedepth = nThe most levels of a recursive collection or referenceMPA-VIEW-8, MPA-VIEW-9, MPA-PLAN-4
recursivechild, to_onerecursive = "cte"Load all levels with one WITH RECURSIVE queryMPA-VIEW-8, MPA-VIEW-9, MPA-PLAN-4
APIWhat it doesRules
mabat::load::<T>()Start a load of the generated queriesMPA-LOAD-1
Load::by_key / by_keysLoad by keysMPA-LOAD-3
Load::filterFilter the root rowsMPA-LOAD-4
Load::order_by / order_by_desc / limit / offsetOrder and page the root rowsMPA-LOAD-6
Load::nestedArguments of a nested collectionMPA-LOAD-9
Load::selectLoad a selection of fields, as JSONMPA-JSON-3
Load::sqlRun SQL as the root query, for reportsMPA-LOAD-19
Load::bindBind a named parameter of the root query’s SQLMPA-LOAD-19
Load::all / one / optional / countRun a loadMPA-LOAD-2
Load::graphLoad a graph viewMPA-LOAD-14
Load::jsonLoad as JSONMPA-JSON-1
Load::graph_jsonLoad a graph as JSON, each entity once with $id and $refMPA-JSON-7
Load::streamLoad a batch at a time, as a streamMPA-LOAD-15, MPA-LOAD-16, MPA-LOAD-17, MPA-LOAD-18
Load::json_streamLoad as JSON a batch at a time, as a streamMPA-LOAD-17
Load::batch_sizeThe number of values a stream loads at a timeMPA-LOAD-15
mabat::saveSave an aggregateMPA-WRITE-3
mabat::save_changesSave what changedMPA-WRITE-8
mabat::save_graphSave every entity of a graphMPA-WRITE-14, MPA-WRITE-15
mabat::save_allSave many values, batched by table and levelMPA-WRITE-19
mabat::save_graph_changesSave the changed entities of a graphMPA-WRITE-20
Graph::is_changedWhether save_graph_changes writes an entityMPA-WRITE-20
mabat::schema::snapshotA snapshot of the database’s schemaMPA-SCH-1
Manifest::check_snapshotCheck the views against a snapshot of the schema, without a databaseMPA-SCH-4, MPA-SCH-5, MPA-SCH-6
mabat_check::buildCheck the views against a snapshot from a build scriptMPA-SCH-7
Graph::insertAdd an entity to a graph, for savingMPA-LOAD-14, MPA-WRITE-14
mabat::deleteDelete an aggregateMPA-WRITE-7
mabat::planThe plan of a viewMPA-PLAN-5
mabat::scaffoldAn override file with the generated SQLMPA-OVR-8
Mabat::builder / Builder::register / overrides_dir / overrides / overrides_sql / on_invalidConfigure a registryMPA-OVR-1, MPA-OVR-5
Builder::check / buildCheck and build a registryMPA-OVR-5
Builder::manifestThe manifest of the viewsMPA-OVR-8
Mabat::load / explain / report / reload / shadow_statsUse a registryMPA-OVR-1, MPA-PLAN-5, MPA-OVR-6, MPA-OVR-7
Pooled::snapshot / read_committedConcurrent loads on a poolMPA-LOAD-11
Selection::new / field / nested / parseBuild a selectionMPA-JSON-3
Graph::root / roots / get / get_mut / all / countRead a graphMPA-LOAD-14
mabat_graphql::schema / SchemaBuilder::list / by_key / registry / connections / finish / into_dynamicA GraphQL schema of viewsMPA-GQL-1