mirror of https://github.com/AMT-Cheif/drift.git
More docs, try to fix pana warnings
This commit is contained in:
parent
d41097d8e5
commit
b79c1c1f57
|
@ -115,7 +115,7 @@ class Batch {
|
|||
rethrow;
|
||||
}
|
||||
} else {
|
||||
return _runWith(_engine.executor);
|
||||
await _runWith(_engine.executor);
|
||||
}
|
||||
|
||||
_engine.markTablesUpdated(_affectedTables);
|
||||
|
|
|
@ -6,6 +6,7 @@ part of 'runtime_api.dart';
|
|||
/// migration logic can live in the main [GeneratedDatabase] class, but code
|
||||
/// can be extracted into [DatabaseAccessor]s outside of that database.
|
||||
/// For details on how to write a dao, see [UseDao].
|
||||
/// [T] should be the associated database class you wrote.
|
||||
abstract class DatabaseAccessor<T extends GeneratedDatabase>
|
||||
extends DatabaseConnectionUser with QueryEngine {
|
||||
@override
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:moor/moor.dart';
|
|||
|
||||
/// Common interface for objects which can be inserted or updated into a
|
||||
/// database.
|
||||
/// [D] is the associated data class.
|
||||
@optionalTypeArgs
|
||||
abstract class Insertable<D extends DataClass> {
|
||||
/// Converts this object into a companion that can be used for inserts. On
|
||||
|
@ -44,6 +45,8 @@ abstract class DataClass {
|
|||
/// An update companion for a [DataClass] which is used to write data into a
|
||||
/// database using [InsertStatement.insert] or [UpdateStatement.write].
|
||||
///
|
||||
/// [D] is the associated data class for this companion.
|
||||
///
|
||||
/// See also:
|
||||
/// - the explanation in the changelog for 1.5
|
||||
/// - https://github.com/simolus3/moor/issues/25
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:convert/convert.dart';
|
|||
part 'custom_type.dart';
|
||||
part 'type_system.dart';
|
||||
|
||||
/// A type that can be mapped from Dart to sql. The generic type parameter here
|
||||
/// A type that can be mapped from Dart to sql. The generic type parameter [T]
|
||||
/// denotes the resolved dart type.
|
||||
abstract class SqlType<T> {
|
||||
/// Constant constructor so that subclasses can be constant
|
||||
|
@ -57,8 +57,9 @@ class BoolType extends SqlType<bool> {
|
|||
}
|
||||
|
||||
@override
|
||||
dynamic mapToSqlVariable(bool content) {
|
||||
int mapToSqlVariable(bool content) {
|
||||
if (content == null) {
|
||||
// ignore: avoid_returning_null
|
||||
return null;
|
||||
}
|
||||
return content ? 1 : 0;
|
||||
|
@ -85,7 +86,7 @@ class StringType extends SqlType<String> implements Monoid<String> {
|
|||
}
|
||||
|
||||
@override
|
||||
dynamic mapToSqlVariable(String content) => content;
|
||||
String mapToSqlVariable(String content) => content;
|
||||
}
|
||||
|
||||
/// Maps [int] values from and to sql
|
||||
|
@ -100,7 +101,7 @@ class IntType extends SqlType<int> implements FullArithmetic<int> {
|
|||
String mapToSqlConstant(int content) => content?.toString() ?? 'NULL';
|
||||
|
||||
@override
|
||||
dynamic mapToSqlVariable(int content) {
|
||||
int mapToSqlVariable(int content) {
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +129,8 @@ class DateTimeType extends SqlType<DateTime>
|
|||
}
|
||||
|
||||
@override
|
||||
dynamic mapToSqlVariable(DateTime content) {
|
||||
int mapToSqlVariable(DateTime content) {
|
||||
// ignore: avoid_returning_null
|
||||
if (content == null) return null;
|
||||
|
||||
return content.millisecondsSinceEpoch ~/ 1000;
|
||||
|
@ -151,7 +153,7 @@ class BlobType extends SqlType<Uint8List> {
|
|||
}
|
||||
|
||||
@override
|
||||
dynamic mapToSqlVariable(Uint8List content) => content;
|
||||
Uint8List mapToSqlVariable(Uint8List content) => content;
|
||||
}
|
||||
|
||||
/// Maps [double] values from and to sql
|
||||
|
@ -173,5 +175,5 @@ class RealType extends SqlType<double> implements FullArithmetic<double> {
|
|||
}
|
||||
|
||||
@override
|
||||
dynamic mapToSqlVariable(num content) => content;
|
||||
num mapToSqlVariable(num content) => content;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue