seshat_maat library
Wires seshat into the Maat framework.
Classes
- BasicWhere
-
column op ? -
BelongsTo<
R> -
posts.user_id → users.id: the parent points at oneR. -
BelongsToMany<
R> -
users ↔ role_user ↔ roles: many-to-many through a pivot table. - BetweenWhere
-
column [not] between ? and ? - Blueprint
- Collects the columns and commands for one table. The schema grammar turns a blueprint into DDL for its dialect.
- Cast
- Converts one column between its database form and its Dart form.
- ColumnDefinition
- One column in a Blueprint, with its fluent modifiers.
- ColumnWhere
-
first op secondwhere both sides are columns. - Connection
- A database connection. Adapters implement the four primitive operations; everything else (query builder, models) is built on them.
- ConnectionBase
- Shared plumbing for adapters: listeners, query log, error wrapping.
- DatabaseServiceProvider
-
Reads
config('database'), opens the default connection and installs it as the process-wide default, so applications configure a database in.envrather than in code. - DB
-
The application's default connection, the Dart spelling of Laravel's
DBfacade. Set it once at startup; models andDB.table()use it unless given another connection explicitly. - DbSeedCommand
-
Runs one registered Seeder by class name (
--class, defaultDatabaseSeeder) — Laravel'sdb:seed --class.migrate:fresh --seedruns every registered seeder instead; this command targets one. - DropColumnCommand
- DropIndexCommand
- ExistsWhere
-
[not] exists (select ...) -
Factory<
T extends Model< T> > - Laravel's model factories. Keyed to the model's ModelDefinition because Dart cannot find a factory by naming convention without reflection.
- Faker
-
Minimal, seedable generators for factories. Deliberately NOT the
fakerpackage: a dependency ofseshat_maatships into every production application, and Dart has no dev-only split for a library's consumers. - ForeignIdDefinition
-
A
foreignIdcolumn that can declare its foreign key inline. - Grammar
- Turns a QueryBuilder into SQL for one dialect. The ANSI defaults here cover SQLite and PostgreSQL; adapters override what differs.
-
HasMany<
R> -
users.id ← posts.user_id: the parent owns manyR. -
HasOne<
R> -
users.id ← profiles.user_id: the parent owns oneR. -
HasOneOrMany<
R> -
Shared mechanics of
hasOneandhasMany: the related table carries foreignKey pointing at the parent's localKey. - IndexCommand
- InSubqueryWhere
-
column [not] in (select ...) - InWhere
-
column [not] in (?, ?, ...) - JoinClause
-
inner|left|right|cross join table on first op second. - MakeFactoryCommand
-
Creates a model factory under
database/factories. - MakeMigrationCommand
-
Creates a timestamped migration file under
database/migrationsand registers it — both animportand a list entry — indatabase/migrations.dart. - MakeModelCommand
-
Creates a model under
lib/app/models, optionally with its migration (-m), factory (-f) and API resource (-r). - MakeResourceCommand
-
Creates an API resource under
lib/app/http/resources. - MakeSeederCommand
-
Creates a new database seeder under
database/seeders. - MigrateCommand
- MigrateFreshCommand
- MigrateRollbackCommand
- MigrateStatusCommand
- Migration
-
One reversible schema change. Subclass it, implement up and down,
and hand instances to a
Migratorin the order they should run. - MigrationStatus
-
A migration's name and the batch it ran in (
null= pending). - Migrator
-
Runs and rolls back Migrations, recording each in a repository table
the way Laravel's
migrationstable does. Every migration runs inside its own transaction, so a failingup()leaves neither its tables nor its repository row behind. On MySQL, DDL statements commit implicitly, so a migration that fails halfway may leave tables behind; the repository row is still not written, so fixing and re-running is safe once you drop what was created. Laravel has the same limitation. -
Model<
T extends Model< T> > -
Base class for models. Subclasses are immutable value objects with
typed fields; persistence methods return new instances rather than
mutating
this. - ModelBinding
-
Laravel's route-model binding:
/widgets/{widget}arrives at the handler as a loaded model, and a missing row is a 404 raised before the handler runs. -
ModelDefinition<
T> -
Everything Seshat keeps in static properties and
boot(): table, key, timestamps, fillable/guarded, casts, relations, global scopes, soft deletes, events. One per model class, declared as a static: -
ModelEvents<
T> - Lifecycle hooks for one model, registered on its ModelDefinition. Nothing runs unless you register something, and everything is visible in one place.
- NestedWhere
-
( ...nested wheres... ) - NullWhere
-
column is [not] null - OrderClause
-
order by column asc|descor raw. -
Paginator<
T> - One page of results plus the numbers a UI needs to draw pagination.
- PostgresConnection
-
A connection to PostgreSQL via
package:postgres(pure Dart). - PostgresGrammar
-
PostgreSQL: native booleans and timestamps;
ilikeavailable. - PostgresSchemaGrammar
- PostgreSQL DDL.
- PrimaryCommand
-
QueryBuilder<
T> -
Fluent, parameterized SQL builder.
Tis what rows hydrate into: a model when built from a ModelDefinition, or a Row map fromDB.table(). - QueryEvent
- Emitted for every statement a connection runs. Subscribe with Connection.listen or turn on Connection.enableQueryLog.
- RawSql
- A fragment of SQL that is written into the statement verbatim.
- RawWhere
- Trusted SQL with its own bindings.
-
Relation<
R> -
A relationship between a parent model and
R. - RelationRegistry
- Collects a model's relations with fully inferred types:
- RenameColumnCommand
- Schema
-
Static schema access on the default connection, like Laravel's
Schemafacade. Use on for another connection. - SchemaBuilder
-
Runs DDL on one connection: the Dart spelling of Laravel's
Schemafacade bound to a connection. - SchemaCommand
- A table-level command collected by a Blueprint.
- SchemaGrammar
- Turns a Blueprint into DDL for one dialect. The defaults here are the ANSI-ish subset SQLite and PostgreSQL share; adapters override type names, literals and the catalogue queries.
- Seeder
-
One database seeder. Subclass it and implement run to insert fixture
or reference data.
migrate:fresh --seedruns the seeders registered withdatabaseCommands(seeders: ...). - SqliteConnection
-
A connection to one SQLite database via
package:sqlite3(FFI). - SqliteGrammar
- SQLite: booleans are integers, timestamps are ISO-8601 text.
- SqliteSchemaGrammar
-
SQLite DDL. Types are loose: everything textual is
text, booleans and dates travel as integers/ISO-8601 text, matchingSqliteGrammar.encode. - WhereClause
-
One entry in a WHERE (or HAVING) list. boolean is
andoror.
Enums
- ColumnType
- The dialect-neutral column types a Blueprint can declare. Each schema grammar maps them to its own SQL type names.
Mixins
-
SoftDeletes<
T extends Model< T> > -
Instance-side soft delete helpers. The query side (the global scope,
withTrashed(),onlyTrashed(),restore(),forceDelete()) is switched on bysoftDeletes: trueon the ModelDefinition; this mixin adds what only makes sense on an instance.
Extensions
-
RequestIncludes
on QueryBuilder<
T> -
RequestPagination
on QueryBuilder<
T>
Constants
-
allowedOperators
→ const Set<
String> - The SQL comparison operators a query may use. Anything else throws.
- softDeletesScope → const String
- Name of the global scope soft deletes register.
Functions
-
assertColumn(
String name) → String -
Like assertIdentifier but also accepts
*andtable.*. -
assertIdentifier(
String name) → String -
Throws InvalidIdentifierException unless
nameis a plain, optionally dot-qualified identifier. This is the single gate through which every table and column name passes before reaching SQL. -
blockedInProduction(
Command command) → bool -
Refuses to run a destructive migration command in production unless
forced.
migrate:freshdrops every table; making that easy to do by accident is how a framework eats someone's data. -
databaseCommands(
{List< Migration> migrations = const [], List<Seeder> seeders = const []}) → List<Command> -
The
migrate*,make:migration,make:model,make:factory,make:resource,make:seederanddb:seedmaat commands, wired tomigrationsandseeders. Register the result inlib/app/console/kernel.dart. -
paginatedResponse<
T> (Paginator< T> page, Request request, {Object? item(T item)?}) → Map<String, Object?> -
Laravel's
data/links/metaenvelope. Paginator.toJson returns a flat map, so the shape is built here rather than delegated. -
parseBool(
Object? value) → bool? -
Accepts
bool,0/1,'true'/'false','t'/'f'. -
parseDateTime(
Object? value) → DateTime? - Accepts DateTime, ISO-8601 text, or milliseconds since the epoch.
-
parseDouble(
Object? value) → double? -
parseEnum<
E extends Enum> (List< E> values, Object? value) → E? -
parseInt(
Object? value) → int? -
parseJson(
Object? value) → Object? -
Accepts a JSON string or an already-decoded
Map/List. -
parseString(
Object? value) → String? -
pgsqlConnectionArgs(
Map config) → ({String database, String host, int maxConnections, String? password, int port, bool ssl, String? username}) -
Maps a
config('database.connections.pgsql')entry to the argumentsPostgresConnection.openaccepts. -
registerDatabaseRules(
) → void -
Registers
uniqueandexistson the validator. Call once at boot — the DatabaseServiceProvider does it for you. -
registerSchemaGrammar(
String driver, SchemaGrammar grammar) → void -
Registers
grammaras the SchemaGrammar for connections whose query grammar name isdriver. Adapters outside this package (a MySQL driver, say) call this once at startup so schemaGrammarFor — and therefore Migrator — can find them. -
resolvePage(
Request request) → int -
Page number from
?page=, defaulting to the first page. -
resolvePerPage(
Request request, {int fallback = 15, int max = 100}) → int -
Page size from
?per_page=, clamped tomax. -
resourceCollection<
T> (Object? items, JsonResource< T> using(T), Request request) → Object? -
Shapes many
Tthroughusing, Laravel'sUserResource::collection(...). -
runMigrationConsole(
List< String> args, Migrator migrator, {StringSink? out, StringSink? err}) → Future<int> -
A tiny
maat migrate-style dispatcher. Returns the process exit code: 0 on success, 1 forhelpor an unknown command. -
schemaGrammarFor(
Connection connection) → SchemaGrammar -
Picks the schema grammar matching
connection's query grammar.
Typedefs
-
AfterHook<
T> = FutureOr< void> Function(T model) - A hook that runs after the fact.
-
Compiled
= (String, List<
Object?> ) - Compiled SQL plus its bindings, in placeholder order.
-
ConnectionFactory
= Future<
Connection> Function(Map<String, dynamic> config) -
Opens a connection from a
config('database')entry. -
GlobalScope<
T> = void Function(QueryBuilder< T> query) -
A global scope:
(q) => q.where('tenant_id', currentTenant). -
RelationConstraint
= void Function(QueryBuilder<
Object?> query) -
Extra constraints for an eager load:
withWhere('posts', (q) => ...). -
Row
= Map<
String, Object?> - One result row, keyed by column name (or alias).
-
VetoHook<
T> = FutureOr< bool?> Function(T model) -
A hook that may veto the operation by returning
false. -
WhereGroup<
T> = void Function(QueryBuilder< T> query) -
A nested where group:
where((q) => q.where(...).orWhere(...)).
Exceptions / Errors
- ConnectionException
- The connection could not be opened, or was lost.
- DatabaseException
- Base class for every error seshat raises.
- InvalidIdentifierException
- A table, column or alias name is not a plain identifier. Use RawSql for anything else, and only with trusted input.
- MassAssignmentException
-
An attribute was mass-assigned through
create()/update()/fill()without being listed infillable(or while beingguarded). - ModelNotFoundException
-
findOrFail/firstOrFailfound nothing. - ModelNotPersistedException
- A model method that only makes sense on a persisted row was called on one that was never saved (or was deleted).
- QueryException
- The driver rejected a statement (syntax, constraint, type...).
- RelationNotLoadedException
-
relation.valuewas read before the relation was eager loaded. - UniqueConstraintException
- A UNIQUE or PRIMARY KEY constraint was violated.