basalt_codegen library Getting Started
build_runner code generator for the Basalt Dart ORM. Wire it via build.yaml;
it derives a RowMapper<T> for every @Queryable class and toInsert() /
toUpdate() extensions for @Insertable / @AsChangeset classes.
Classes
- AsChangesetGenerator Getting Started
-
Emits a
toUpdate()extension for each@AsChangesetdata class. - ChangesetEmitter
-
Emits a
toUpdate()extension that builds anUpdateStatement<Tbl>whoseSETclause covers every writable column (everything except@Column(readOnly: true)); the caller appends.where(...), typically on the primary key. Pure string emit, so it is unit-testable without the analyzer. - ClassInfo
-
Everything the code generator needs to know about a single
@Queryableclass, resolved from its element. Collected for the whole relation closure reachable from a generated class so each.g.dartis self-contained — it never references generated symbols from another library. - ColumnArg
-
One constructor column mapped to a schema accessor expression, plus its
read/write direction from
@Column(readOnly:)/@Column(writeOnly:). - EdgeAnalyzer
-
Parses
@Relation/@Columnmetadata from analyzer elements. - InsertableGenerator Getting Started
-
Emits a
toInsert()extension for each@Insertabledata class — on the class itself (single-row insert) and onIterableof it (one multi-row batchINSERT). Independent of@Queryable, so a write-only DTO works on its own. - InsertEmitter
-
Emits a
toInsert()extension that builds anInsertStatement<Tbl>from a data class instance, setting every writable column (everything except@Column(readOnly: true)) viaTableColumn.set. Pure string emit, so it is unit-testable without the analyzer. - ModelCodeGenerator
-
Generates the
${Class}Querycompanion from a resolved QueryableModel. - QueryableClassCodegen
- Bridges analyzer metadata to ModelCodeGenerator.
- QueryableGenerator Getting Started
-
Generates a
${Class}Querycompanion for each@Queryableclass — the companion is the canonical query (extends MappedQuery/FoldMappedQuery) and carries the alias-parameterizedstatic fromRowreader plus itsRowMapper.@Relationfields drive nested joins with per-edge depth limits and path-based table aliases. - QueryableModel
-
Root inputs for one
@Queryableclass plus the resolved info for every class reachable through its relations (classInfos, keyed by class name). The closure makes generation self-contained across files: the emitted.g.dartdefines every nested reader it needs locally. - QueryGetterEmitter
-
Emits the constructor +
_build()/_decodemembers of a${Class}Querycompanion whose query joins the class's@Relationtargets with aliased joins. - ReaderEmitter
-
Emits the public, alias-parameterized
static fromRowreader member of the generated${Class}Querycompanion. - RelationArg
- A nested relation argument inlined into a unified reader.
- RelationCallEmitter
- Builds the inline relation expressions placed inside a unified reader.
- RelationEdge
-
A
@Relationedge extracted from a constructor parameter. - RelationTreeBuilder
- Unrolls join trees for relation queries with path-based table aliases.
- SelectQueryEmitter
-
Emits the constructor +
_build()members of a${Class}Querycompanion for a@Queryableclass that has no relations: the query selects exactly the class's readable columns (a column subset of the table) and decodes them withfromRow. This is the "Selectable" analog — projecting a chosen set of columns into a lightweight view class, sodb.fetch(UserQuery())reads only those columns instead ofSELECT *. - TreeNode
- One node in the unrolled join tree for a relation query.
Extensions
- ModelCodeGeneratorJoin on ModelCodeGenerator
- Convenience for callers that want a single chunk (e.g. tests).
Constants
- aggChecker → const TypeChecker
- asChangesetChecker → const TypeChecker
- columnChecker → const TypeChecker
- hasManyChecker → const TypeChecker
- insertableChecker → const TypeChecker
- queryableChecker → const TypeChecker
- relationChecker → const TypeChecker
Functions
-
camelCase(
String snake) → String -
generateQueryableClass(
ClassElement element) → Iterable< String> -
Generates code units for a single
@Queryable-annotatedelement. -
lowerFirst(
String s) → String -
queryableBuilder(
BuilderOptions options) → Builder Getting Started -
build_runner entry point (wired in
build.yaml). Emits a shared part so the generated readers/mappers andtoInsert()/toUpdate()extensions live in<file>.g.dartalongside the user's classes. A class can carry several of@Queryable/@Insertable/@AsChangeset; each generator contributes its own (non-overlapping) units to the same part. -
ucFirst(
String s) → String -
validateRelationDepth(
int depth, Element element) → int - Top-level so the depth guard is unit-testable without analyzer mocks.
Typedefs
-
RelationEdgesLookup
= List<
RelationEdge> Function(String targetClass)