Client class abstract
Abstract base class for database clients
Each database dialect (PostgreSQL, MySQL, SQLite, etc.) extends this class to provide dialect-specific implementations of query compilation, connection management, and SQL generation.
Constructors
- Client(KnexConfig config)
Properties
- config → KnexConfig
-
Configuration for this client
final
- driverName → String
-
Get the driver name for this client (e.g., 'pg', 'mysql', 'sqlite3')
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger → Logger
-
Logger for this client
final
-
onQuery
→ Stream<
QueryEvent> -
Stream of query events
no setter
-
onQueryError
→ Stream<
QueryErrorEvent> -
Stream of query error events
no setter
-
onQueryResponse
→ Stream<
QueryResponseEvent> -
Stream of query response events
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
acquireConnection(
) → Future - Acquire a connection from the pool
-
alias(
String value, String alias) → String - Format value AS alias for SQL
-
destroy(
) → Future< void> - Destroy the connection pool and close all connections
-
emitQuery(
String sql, List bindings, String uid, [String? txId]) → void - Emit a query event
-
emitQueryError(
Object error, StackTrace stackTrace, String sql, List bindings, [String? uid]) → void - Emit a query error event
-
emitQueryResponse(
dynamic response, String sql, List bindings, String uid, [QueryBuilder? builder]) → void - Emit a query response event
-
formatter(
dynamic builder) → dynamic - Get a formatter for the given builder
-
formatValue(
dynamic value) → String - Format a value for SQL (escaping as needed)
-
initializeDriver(
) → void - Initialize the database driver
-
initializePool(
[PoolConfig? poolConfig]) → void - Initialize the connection pool
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parameter(
dynamic value, List bindings) → String - Add a value to bindings and return the parameter placeholder
-
parameterPlaceholder(
int index) → String - Get parameter placeholder for given position (1-indexed)
-
positionBindings(
String sql) → String - Position bindings in SQL (convert ? to dialect-specific placeholders)
-
postProcessResponse(
dynamic response, dynamic queryContext) → dynamic - Post-process query response (apply custom transformations)
-
prepareBindings(
List bindings) → List - Prepare bindings for the query (dialect-specific formatting)
-
query(
dynamic connection, String sql, List bindings) → Future< List< Map< >String, dynamic> > - Execute a query and return results
-
queryBuilder(
) → QueryBuilder - Create a new query builder
-
queryCompiler(
QueryBuilder builder) → QueryCompiler - Create a new query compiler
-
raw(
String sql, [dynamic bindings]) → Raw - Create a new raw query
-
rawQuery(
String sql, List bindings) → Future - Execute a raw SQL query
-
ref(
String columnRef) → Ref - Create a new column reference
-
releaseConnection(
dynamic connection) → Future< void> - Release a connection back to the pool
-
runInTransaction<
T> (Future< T> action()) → Future<T> -
Run
actioninside a database transaction on a single pinned connection. -
schemaBuilder(
) → SchemaBuilder - Create a new schema builder
-
schemaCompiler(
SchemaBuilder builder) → SchemaCompiler - Create a new schema compiler
-
streamQuery(
dynamic connection, String sql, List bindings) → Stream< Map< String, dynamic> > - Stream query results (for large result sets)
-
toString(
) → String -
A string representation of this object.
inherited
-
transaction(
[TransactionConfig? config]) → Future< Transaction> - Start a new transaction
-
wrapIdentifier(
String identifier) → String - Wrap an identifier (table/column name) with the dialect-specific wrapper
-
wrapIdentifierImpl(
String identifier) → String - Dialect-specific identifier wrapping implementation
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited