moor library

Classes

ArgumentsForBatchedStatement
Instruction to run a batched sql statement with the arguments provided.
Batch
Contains operations to run queries in a batched mode. This can be much more efficient when running a lot of similar queries at the same time, making this api suitable for bulk updates.
BatchedStatements
Stores information needed to run batched statements in the order they were issued without preparing statements multiple times.
BeforeOpenRunner
Special query engine to run the MigrationStrategy.beforeOpen callback. [...]
BlobColumn
A column that stores arbitrary blobs of data as a Uint8List.
BlobColumnBuilder
Tells the generator to build an BlobColumn. See the docs at ColumnBuilder for details.
BlobType
Maps Uint8List values from and to sql
BoolColumn
A column that stores boolean values. Booleans will be stored as an integer that can either be 0 (false) or 1 (true).
BoolColumnBuilder
Tells the generator to build an BoolColumn. See the docs at ColumnBuilder for details.
BoolType
A mapper for boolean values in sql. Booleans are represented as integers, where 0 means false and any other value means true.
Column<T>
Base class for columns in sql. Type T refers to the type a value of this column will have in Dart.
ColumnBuilder<Builder, ResultColumn extends Column<ResultDartType>, ResultDartType>
A column builder is used to specify which columns should appear in a table. All of the methods defined in this class and its subclasses are not meant to be called at runtime. Instead, moor_generator will take a look at your source code (specifically, it will analyze which of the methods you use) to figure out the column structure of a table.
Component
A component is anything that can appear in a sql query.
Constant<T>
An expression that represents the value of a dart object encoded to sql by writing them into the sql statements. For most cases, consider using Variable instead.
CustomExpression<D>
A custom expression that can appear in a sql statement. The CustomExpression.content will be written into the query without any modification. [...]
CustomSelectStatement
A select statement that is constructed with a raw sql prepared statement instead of the high-level moor api.
DatabaseAccessor<T extends GeneratedDatabase>
Class that runs queries to a subset of all available queries in a database. [...]
DatabaseConnection
A database connection managed by moor. Contains three components: [...]
DatabaseConnectionUser
Manages a DatabaseConnection to send queries to the database.
DatabaseSchemaEntity
Some abstract schema entity that can be stored in a database. This includes tables, triggers, views, indexes, etc.
DataClass
A common supertype for all data classes generated by moor. Data classes are immutable structures that represent a single row in a database table.
DataClassName
A class to be used as an annotation on Table classes to customize the name for the data class that will be generated for the table class. The data class is a dart object that will be used to represent a row in the table. {@template moor_custom_data_class} By default, moor will attempt to use the singular form of the table name when naming data classes (e.g. a table named "Users" will generate a data class called "User"). However, this doesn't work for irregular plurals and you might want to choose a different name, for which this annotation can be used. {@template}
DateTimeColumn
A column that stores a DateTime. Times will be stored as unix timestamp and will thus have a second accuracy.
DateTimeColumnBuilder
Tells the generator to build an DateTimeColumn. See the docs at ColumnBuilder for details.
DateTimeType
Maps DateTime values from and to sql
DeleteStatement<T extends Table, D extends DataClass>
A DELETE statement in sql
DoUpdate<T extends Table, D extends DataClass>
A DoUpdate upsert clause can be used to insert or update a custom companion when the underlying companion already exists. [...]
EnumIndexConverter<T>
Implementation for an enum to int converter that uses the index of the enum as the value stored in the database.
Expression<D>
Any sql expression that evaluates to some generic value. This does not include queries (which might evaluate to multiple values) but individual columns, functions and operators. [...]
FunctionCallExpression<R>
A sql expression that calls a function. [...]
FunctionParameter
Base class for everything that can be used as a function parameter in sql. [...]
GeneratedBlobColumn
Implementation for BlobColumn
GeneratedBoolColumn
Implementation for BoolColumn.
GeneratedColumn<T>
Base class for the implementation of Column.
GeneratedDatabase
A base class for all generated databases.
GeneratedDateTimeColumn
Implementation for DateTimeColumn.
GeneratedIntColumn
Implementation for IntColumn
GeneratedRealColumn
Implementation for RealColumn
GeneratedTextColumn
Implementation for TextColumn.
GenerationContext
Contains information about a query while it's being constructed.
GroupBy
A "group by" clause in sql.
Index
A sqlite index on columns or expressions. [...]
Insertable<D extends DataClass>
Common interface for objects which can be inserted or updated into a database. D is the associated data class.
InsertStatement<T extends Table, D extends DataClass>
Represents an insert statement
IntColumn
A column that stores int values.
IntColumnBuilder
Tells the generator to build an IntColumn. See the docs at ColumnBuilder for details.
IntType
Maps int values from and to sql
Join<T extends Table, D extends DataClass>
Used internally by moor when calling SimpleSelectStatement.join. [...]
JoinedSelectStatement<FirstT extends Table, FirstD extends DataClass>
A SELECT statement that operates on more than one table.
JsonKey
Annotation to use on column getters inside of a Table to define the name of the column in the json used by DataClass.toJson. [...]
LazyDatabase
A special database executor that delegates work to another QueryExecutor. The other executor is lazily opened by a DatabaseOpener.
Limit
A limit clause inside a select, update or delete statement.
MigrationStrategy
Handles database migrations by delegating work to OnCreate and OnUpgrade methods.
Migrator
Runs migrations declared by a MigrationStrategy.
MoorRuntimeOptions
Defines additional runtime behavior for moor. Changing the fields of this class is rarely necessary.
MultiExecutor
A query executor for moor that delegates work to multiple executors.
OnCreateQuery
An internal schema entity to run an sql statement when the database is created. [...]
OpeningDetails
Provides information about whether migrations ran before opening the database.
OrderBy
An order-by clause as part of a select statement. The clause can consist of multiple OrderingTerms, with the first terms being more important and the later terms only being considered if the first term considers two rows equal.
OrderingTerm
A single term in a OrderBy clause. The priority of this term is determined by its position in OrderBy.terms.
Precedence
Used to order the precedence of sql expressions so that we can avoid unnecessary parens when generating sql statements.
Query<T extends Table, D extends DataClass>
Statement that operates with data that already exists (select, delete, update).
QueryExecutor
A query executor is responsible for executing statements on a database and return their results in a raw form. [...]
QueryExecutorUser
Callbacks passed to QueryExecutor.ensureOpen to run schema migrations when the database is first opened.
QueryRow
For custom select statements, represents a row in the result set.
RawValuesInsertable<D extends DataClass>
An Insertable implementation based on raw column expressions. [...]
RealColumn
A column that stores floating point numeric values.
RealColumnBuilder
Tells the generator to build an RealColumn. See the docs at ColumnBuilder for details.
RealType
Maps double values from and to sql
Selectable<T>
Abstract class for queries which can return one-time values or a stream of values.
SimpleSelectStatement<T extends Table, D extends DataClass>
A select statement that doesn't use joins
SqlType<T>
A type that can be mapped from Dart to sql. The generic type parameter T denotes the resolved dart type.
SqlTypeSystem
Manages the set of SqlType known to a database. It's also responsible for returning the appropriate sql type for a given dart type.
StreamQueryUpdateRules
Collects a set of UpdateRules which can be used to express how a set of direct updates to a table affects other updates. [...]
StringType
Mapper for string values in sql.
Table
Subclasses represent a table in a database generated by moor.
TableUpdate
Contains information on how a table was updated, which can be used to find queries that are affected by this.
TableUpdateQuery
A table update query describes information to listen for TableUpdates. [...]
TextColumn
A column that stores text.
TextColumnBuilder
Tells the generator to build an TextColumn. See the docs at ColumnBuilder for details.
Transaction
Runs multiple statements transactionally. [...]
TransactionExecutor
A QueryExecutor that runs multiple queries atomically.
Trigger
A sqlite trigger that's executed before, after or instead of a subset of writes on a specific tables. In moor, triggers can only be declared in .moor files. [...]
TypeConverter<D, S>
Maps a custom dart object of type D into a primitive type S understood by the sqlite backend. [...]
TypedResult
A result row in a JoinedSelectStatement that can parse the result of multiple entities.
Uint8List
A fixed-length list of 8-bit unsigned integers. [...]
UpdateCompanion<D extends DataClass>
An update companion for a DataClass which is used to write data into a database using InsertStatement.insert or UpdateStatement.write. [...]
UpdateRule
A common rule that describes how a TableUpdate has other TableUpdates. [...]
UpdateStatement<T extends Table, D extends DataClass>
Represents an UPDATE statement in sql.
UseDao
Annotation to use on classes that implement DatabaseAccessor. It specifies which tables should be made available in this dao. [...]
UseMoor
Use this class as an annotation to inform moor_generator that a database class should be generated using the specified UseMoor.tables. [...]
Value<T>
A wrapper around arbitrary data T to indicate presence or absence explicitly. We can use Values in companions to distinguish between null and absent values.
ValueSerializer
Serializer responsible for mapping atomic types from and to json.
Variable<T>
An expression that represents the value of a dart object encoded to sql using prepared statements.
VerificationContext
Used internally by moor for integrity checks.
VerificationMeta
Additional information that is passed to GeneratedColumns when verifying data to provide more helpful error messages.
VerificationResult
Returned by GeneratedColumn.isAcceptableValue to provide a description when a valid is invalid.
Where
A where clause in a select, update or delete statement.
WritePropagation
An UpdateRule for triggers that exist in a database. [...]

Mixins

LimitContainerMixin<T extends Table, D extends DataClass>
Mixin to provide the high-level limit methods for users.
QueryEngine
Mixin for a DatabaseConnectionUser. Provides an API to execute both high-level and custom queries and fetch their results.
SingleTableQueryMixin<T extends Table, D extends DataClass>
TableInfo<TableDsl extends Table, D extends DataClass>
Base class for generated classes. TableDsl is the type specified by the user that extends Table, D is the type of the data class generated from the table.
VirtualTableInfo<TableDsl extends Table, D extends DataClass>
Additional interface for tables in a moor file that have been created with an CREATE VIRTUAL TABLE STATEMENT.

Extensions

ArithmeticAggregates
Provides aggregate functions that are available for numeric expressions.
ArithmeticExpr
Defines the -, * and / operators on sql expressions that support it.
BaseAggregate
Provides aggregate functions that are available for each expression.
BooleanExpressionOperators
Defines operations on boolean values.
ComparableExpr
Defines extension functions to express comparisons in sql
DateTimeExpressions
Provides expressions to extract information from date time values, or to calculate the difference between datetimes.
DestructiveMigrationExtension
Extension providing the destructiveFallback strategy.
OldDbFieldInDatabaseAccessor
Extension for generated dao classes to keep the old db field that was renamed to DatabaseAccessor.attachedDatabase in moor 3.0
StringExpressionOperators
Defines methods that operate on a column storing String values.
TableInfoUtils
Static extension members for generated table classes. [...]

Constants

currentDate → const Expression<DateTime>
A sql expression that evaluates to the current date represented as a unix timestamp. The hour, minute and second fields will be set to 0.
const _CustomDateTimeExpression("strftime('%s', CURRENT_DATE)")
currentDateAndTime → const Expression<DateTime>
A sql expression that evaluates to the current date and time, similar to DateTime.now. Timestamps are stored with a second accuracy.
const _CustomDateTimeExpression("strftime('%s', CURRENT_TIMESTAMP)")
required → const Required
Used to annotate a named parameter p in a method or function f. Indicates that every invocation of f must include an argument corresponding to p, despite the fact that p would otherwise be an optional parameter. [...]
const Required()

Properties

moorRuntimeOptions MoorRuntimeOptions
Stores the MoorRuntimeOptions describing global moor behavior across databases. [...]
read / write

Functions

$expandVar(int start, int amount) String
Used by generated code.
$mrjc(int hash, int value) int
For use by generated code in calculating hash codes. Do not use directly.
$mrjf(int hash) int
For use by generated code in calculating hash codes. Do not use directly.
countAll({Expression<bool> filter}) Expression<int>
Returns the amount of rows in the current group matching the optional filter. [...]
crossJoin<T, D>(TableInfo<Table, DataClass> other, {bool useColumns}) Join<Table, DataClass>
Creates a sql cross join that can be used in SimpleSelectStatement.join. [...]
innerJoin<T extends Table, D extends DataClass>(TableInfo<T, D> other, Expression<bool> on, {bool useColumns}) Join<Table, DataClass>
Creates a sql inner join that can be used in SimpleSelectStatement.join. [...]
isNotNull(Expression inner) Expression<bool>
Expression that is true if the inner expression resolves to a non-null value.
isNull(Expression inner) Expression<bool>
Expression that is true if the inner expression resolves to a null value.
leftOuterJoin<T extends Table, D extends DataClass>(TableInfo<T, D> other, Expression<bool> on, {bool useColumns}) Join<Table, DataClass>
Creates a sql left outer join that can be used in SimpleSelectStatement.join. [...]

Enums

Collate
Builtin collating functions from sqlite. [...]
InsertMode
Enumeration of different insert behaviors. See the documentation on the individual fields for details.
OrderingMode
Describes how to order rows
SqlDialect
An enumeration of database systems supported by moor. Only SqlDialect.sqlite is officially supported, all others are in an experimental state at the moment.
UpdateKind
Classifies a TableUpdate by what kind of write happened - an insert, an update or a delete operation.

Typedefs

DatabaseOpener() FutureOr<QueryExecutor>
Signature of a function that opens a database connection when instructed to.
OnBeforeOpen(OpeningDetails details) Future<void>
Signature of a function that's called before a database is marked opened by moor, but after migrations took place. This is a suitable callback to to populate initial data or issue PRAGMA statements that you want to use.
OnCreate(Migrator m) Future<void>
Signature of a function that will be invoked when a database is created.
OnUpgrade(Migrator m, int from, int to) Future<void>
Signature of a function that will be invoked when a database is upgraded or downgraded. In version upgrades: from < to In version downgrades: from > to
OrderClauseGenerator<T>(T tbl) OrderingTerm
Signature of a function that generates an OrderingTerm when provided with a table.

Exceptions / Errors

InvalidDataException
Thrown when one attempts to insert or update invalid data into a table.
MoorWrappedException
A wrapper class for internal exceptions thrown by the underlying database engine when moor can give additional context or help. [...]