DataSourceOptions class
Configuration options for initializing a DataSource.
Provides a declarative way to configure the ORM with all required components in a single object.
final options = DataSourceOptions(
driver: SqliteDriverAdapter.file('app.sqlite'),
entities: [UserOrmDefinition.definition, PostOrmDefinition.definition],
);
Constructors
-
DataSourceOptions({required DriverAdapter driver, List<
ModelDefinition< entities = const [], ModelRegistry? registry, ScopeRegistry? scopeRegistry, String name = 'default', String? database, String tablePrefix = '', String? defaultSchema, Map<OrmEntity> >String, ValueCodec> codecs = const {}, List<DriverExtension> driverExtensions = const [], List<QueryInterceptor> interceptors = const [], bool logging = false, String? logFilePath, Logger? logger, String carbonTimezone = 'UTC', String carbonLocale = 'en_US', bool enableNamedTimezones = false})
Properties
- carbonLocale → String
-
Default locale for Carbon date/time formatting.
Defaults to 'en_US'. Supports 170+ locales like 'fr_FR', 'es_ES', etc.
final
- carbonTimezone → String
-
Default timezone for Carbon date/time instances.
Defaults to 'UTC'. Use 'America/New_York', 'Europe/London', etc.
for named timezones (requires enableNamedTimezones = true).
final
-
codecs
→ Map<
String, ValueCodec> -
Additional value codecs to register beyond the standard set.
final
- database → String?
-
Optional database/catalog identifier for observability.
final
- defaultSchema → String?
-
Default schema applied to ad-hoc tables when not specified.
final
- driver → DriverAdapter
-
The database driver adapter to use for connections.
final
-
driverExtensions
→ List<
DriverExtension> -
Driver extension modules registered for this data source.
final
- enableNamedTimezones → bool
-
Whether to enable named timezone support via TimeMachine.
Set to true if you need named timezones like 'America/New_York'.
UTC and fixed offsets ('+05:30') work without this.
final
-
entities
→ List<
ModelDefinition< OrmEntity> > -
List of model definitions (entities) to register with this data source.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
interceptors
→ List<
QueryInterceptor> -
Middleware applied to query-builder, raw SQL, and transaction execution.
final
- logFilePath → String?
-
Optional base file path for contextual logging output.
final
- logger → Logger?
-
Optional contextual logger used for default query logging.
final
- logging → bool
-
Whether to enable query logging and default contextual query logs.
final
- name → String
-
Logical name for this connection. Defaults to 'default'.
final
- registry → ModelRegistry?
-
Optional pre-built model registry with type aliases already registered.
If provided, this registry will be used instead of creating a new one.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scopeRegistry → ScopeRegistry?
-
Optional scope registry to use for this data source.
final
- tablePrefix → String
-
Table prefix automatically applied by some schemas.
final
Methods
-
copyWith(
{DriverAdapter? driver, List< ModelDefinition< ? entities, ModelRegistry? registry, ScopeRegistry? scopeRegistry, String? name, String? database, String? tablePrefix, String? defaultSchema, Map<OrmEntity> >String, ValueCodec> ? codecs, List<DriverExtension> ? driverExtensions, List<QueryInterceptor> ? interceptors, bool? logging, String? logFilePath, Logger? logger, String? carbonTimezone, String? carbonLocale, bool? enableNamedTimezones}) → DataSourceOptions -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited