knex library
Knex Dart - SQL Query Builder
A batteries-included SQL query builder for Dart inspired by Knex.js. For documentation and examples, see knex_dart.dart
Classes
- AnalyticClause
- The AnalyticClause is used for window / analytic functions (row_number, rank, dense_rank) when a callback is passed.
- Client
- Abstract base class for database clients
- CodeMigrationSource
- Simple source backed by an in-memory list of migration units.
- ColumnBuilder
- A fluent builder for a column definition in a CREATE TABLE or ALTER TABLE statement.
- ExternalSchemaAdapter
- Adapter contract for translating external schema formats into KnexSchemaAst.
- ForeignBuilder
- Fluent builder for foreign key constraints on TableBuilder.
- Formatter
- Formatter for wrapping identifiers and formatting SQL components
- JoinClause
- JoinClause for complex JOIN ON conditions
- JsonSchemaAdapter
- Maps JSON Schema documents into KnexSchemaAst.
- Knex
- Main Knex factory class — pure query-builder wrapper.
- KnexColumnAst
- One column definition in the schema AST.
- KnexConfig
- Configuration for Knex instance
- KnexForeignKeyAst
- Optional foreign key reference metadata.
- KnexSchemaAst
- Canonical, dialect-neutral schema AST.
- KnexTableAst
- One table in the schema AST.
- Migration
- Backward-compatible base type for user-defined migrations.
- MigrationConfig
- Migration configuration
- MigrationSource
- Source abstraction for loading migration units.
- MigrationUnit
- One executable migration unit with an explicit name and reversible steps.
- Migrator
- Orchestrates migration discovery, execution, rollback, and status reporting.
- OnConflictBuilder
- Fluent builder for ON CONFLICT / INSERT IGNORE / ON DUPLICATE KEY UPDATE
- Op
-
Pre-defined SQL operator constants for use with
where(),having(),onVal(), and similar methods. - PoolConfig
- Connection pool configuration
- QueryBuilder
- Query builder for constructing SQL queries
- QueryCompiler
- Query compiler that transforms QueryBuilder statements into SQL
- QueryErrorEvent
- Event emitted when a query fails
- QueryEvent
- Event emitted when a query is executed
- QueryResponseEvent
- Event emitted when a query succeeds
- Raw
- Represents a raw SQL query or expression
- Ref
- Column reference that should behave like a Raw fragment
- SchemaAdapterRegistry
- Simple adapter registry for plugin-style schema format resolution.
- SchemaAstMigration
- Migration that projects schema AST into CREATE TABLE DDL.
- SchemaAstProjector
- Projects KnexSchemaAst into the existing SchemaBuilder API.
- SchemaBuilder
- Schema builder for DDL operations.
- SchemaCompiler
- Compiles SchemaBuilder DDL operations into SQL statements.
- SchemaFormatAdapter
- Backward-compatible alias for existing code and docs.
- SeedConfig
- Seed configuration
- SqlDirectoryMigrationSource
- Filesystem-backed SQL migration source.
- SqlMigration
- SQL-first migration implementation.
- SqlString
- Represents a compiled SQL query with its bindings
- TableBuilder
- Table builder for defining table schema through a callback.
- Transaction
- Transaction class
- TransactionConfig
- Transaction configuration
- WindowSpec
- Window function specification for OVER (...) clause.
Enums
- ColumnType
- Column data types (for schema builder)
- ComparisonOperator
- Comparison operators
- ConflictAction
- Conflict resolution strategies for ON CONFLICT
- ForeignKeyAction
- Foreign key actions
- IsolationLevel
- Transaction isolation levels
- JoinType
- Join types
- KnexColumnType
- Supported logical column kinds.
- LockMode
- Row-level lock modes
- OrderDirection
- ORDER BY direction
- QueryMethod
- Query method types
- WaitMode
- Lock wait modes
Extensions
- JsonQueryBuilder on QueryBuilder
- Extension adding JSON-specific querying capabilities to QueryBuilder.
Typedefs
-
BindingList
= List<
BindingValue?> - List of binding values
- BindingValue = Object?
- Value for SQL binding Can be String, num, bool, List, Map, DateTime, null
- ConnectionConfig = Object
- Connection configuration Can be a Map for connection parameters or a String for connection URI
- DatabaseConnection = dynamic
- Database connection Type depends on the driver (pg.Connection, mysql.Connection, etc.) Will be refined per-dialect in Phase 2
- JoinClauseCallback = void Function(JoinClause join)
- Typed callback for join ON clause builders.
- QueryBuilderCallback = void Function(QueryBuilder qb)
- Typed callback for subquery/grouped query builders.
-
QueryContext
= Map<
String, dynamic> - Query context for post-processing
-
QueryResult
= List<
Map< String, dynamic> > - Result from a database query This is intentionally dynamic as different drivers return different types, but will be typed per-driver in Phase 2
- RawQueryResult = dynamic
- Raw query result (driver-specific) Will be refined per-dialect in Phase 2
Exceptions / Errors
- KnexConnectionException
- Exception thrown when connection cannot be acquired
- KnexException
- Base exception class for all Knex errors
- KnexMigrationException
- Exception thrown when migration fails
- KnexMigrationLockException
- Exception thrown when migration table is locked
- KnexQueryException
- Exception thrown for invalid query construction
- KnexTimeoutException
- Exception thrown when query times out
- KnexTransactionException
- Exception thrown when transaction fails