mirror of https://github.com/AMT-Cheif/drift.git
263 lines
8.4 KiB
Dart
263 lines
8.4 KiB
Dart
// GENERATED CODE, DO NOT EDIT BY HAND.
|
|
// ignore_for_file: type=lint
|
|
//@dart=2.12
|
|
import 'package:drift/drift.dart';
|
|
|
|
class Todos extends Table with TableInfo<Todos, TodosData> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
Todos(this.attachedDatabase, [this._alias]);
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
late final GeneratedColumn<String> title = GeneratedColumn<String>(
|
|
'title', aliasedName, false,
|
|
additionalChecks:
|
|
GeneratedColumn.checkTextLength(minTextLength: 6, maxTextLength: 10),
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: true);
|
|
late final GeneratedColumn<String> content = GeneratedColumn<String>(
|
|
'body', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
late final GeneratedColumn<int> category = GeneratedColumn<int>(
|
|
'category', aliasedName, true,
|
|
type: DriftSqlType.int, requiredDuringInsert: false);
|
|
late final GeneratedColumn<DateTime> dueDate = GeneratedColumn<DateTime>(
|
|
'due_date', aliasedName, true,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [id, title, content, category, dueDate];
|
|
@override
|
|
String get aliasedName => _alias ?? 'todos';
|
|
@override
|
|
String get actualTableName => 'todos';
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
TodosData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return TodosData(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
title: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
|
content: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}body'])!,
|
|
category: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}category']),
|
|
dueDate: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}due_date']),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Todos createAlias(String alias) {
|
|
return Todos(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class TodosData extends DataClass implements Insertable<TodosData> {
|
|
final int id;
|
|
final String title;
|
|
final String content;
|
|
final int? category;
|
|
final DateTime? dueDate;
|
|
const TodosData(
|
|
{required this.id,
|
|
required this.title,
|
|
required this.content,
|
|
this.category,
|
|
this.dueDate});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['title'] = Variable<String>(title);
|
|
map['body'] = Variable<String>(content);
|
|
if (!nullToAbsent || category != null) {
|
|
map['category'] = Variable<int>(category);
|
|
}
|
|
if (!nullToAbsent || dueDate != null) {
|
|
map['due_date'] = Variable<DateTime>(dueDate);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
TodosCompanion toCompanion(bool nullToAbsent) {
|
|
return TodosCompanion(
|
|
id: Value(id),
|
|
title: Value(title),
|
|
content: Value(content),
|
|
category: category == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(category),
|
|
dueDate: dueDate == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(dueDate),
|
|
);
|
|
}
|
|
|
|
factory TodosData.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return TodosData(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
title: serializer.fromJson<String>(json['title']),
|
|
content: serializer.fromJson<String>(json['content']),
|
|
category: serializer.fromJson<int?>(json['category']),
|
|
dueDate: serializer.fromJson<DateTime?>(json['dueDate']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'title': serializer.toJson<String>(title),
|
|
'content': serializer.toJson<String>(content),
|
|
'category': serializer.toJson<int?>(category),
|
|
'dueDate': serializer.toJson<DateTime?>(dueDate),
|
|
};
|
|
}
|
|
|
|
TodosData copyWith(
|
|
{int? id,
|
|
String? title,
|
|
String? content,
|
|
Value<int?> category = const Value.absent(),
|
|
Value<DateTime?> dueDate = const Value.absent()}) =>
|
|
TodosData(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
content: content ?? this.content,
|
|
category: category.present ? category.value : this.category,
|
|
dueDate: dueDate.present ? dueDate.value : this.dueDate,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TodosData(')
|
|
..write('id: $id, ')
|
|
..write('title: $title, ')
|
|
..write('content: $content, ')
|
|
..write('category: $category, ')
|
|
..write('dueDate: $dueDate')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, title, content, category, dueDate);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is TodosData &&
|
|
other.id == this.id &&
|
|
other.title == this.title &&
|
|
other.content == this.content &&
|
|
other.category == this.category &&
|
|
other.dueDate == this.dueDate);
|
|
}
|
|
|
|
class TodosCompanion extends UpdateCompanion<TodosData> {
|
|
final Value<int> id;
|
|
final Value<String> title;
|
|
final Value<String> content;
|
|
final Value<int?> category;
|
|
final Value<DateTime?> dueDate;
|
|
const TodosCompanion({
|
|
this.id = const Value.absent(),
|
|
this.title = const Value.absent(),
|
|
this.content = const Value.absent(),
|
|
this.category = const Value.absent(),
|
|
this.dueDate = const Value.absent(),
|
|
});
|
|
TodosCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String title,
|
|
required String content,
|
|
this.category = const Value.absent(),
|
|
this.dueDate = const Value.absent(),
|
|
}) : title = Value(title),
|
|
content = Value(content);
|
|
static Insertable<TodosData> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? title,
|
|
Expression<String>? content,
|
|
Expression<int>? category,
|
|
Expression<DateTime>? dueDate,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (title != null) 'title': title,
|
|
if (content != null) 'body': content,
|
|
if (category != null) 'category': category,
|
|
if (dueDate != null) 'due_date': dueDate,
|
|
});
|
|
}
|
|
|
|
TodosCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? title,
|
|
Value<String>? content,
|
|
Value<int?>? category,
|
|
Value<DateTime?>? dueDate}) {
|
|
return TodosCompanion(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
content: content ?? this.content,
|
|
category: category ?? this.category,
|
|
dueDate: dueDate ?? this.dueDate,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (title.present) {
|
|
map['title'] = Variable<String>(title.value);
|
|
}
|
|
if (content.present) {
|
|
map['body'] = Variable<String>(content.value);
|
|
}
|
|
if (category.present) {
|
|
map['category'] = Variable<int>(category.value);
|
|
}
|
|
if (dueDate.present) {
|
|
map['due_date'] = Variable<DateTime>(dueDate.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TodosCompanion(')
|
|
..write('id: $id, ')
|
|
..write('title: $title, ')
|
|
..write('content: $content, ')
|
|
..write('category: $category, ')
|
|
..write('dueDate: $dueDate')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class DatabaseAtV2 extends GeneratedDatabase {
|
|
DatabaseAtV2(QueryExecutor e) : super(e);
|
|
late final Todos todos = Todos(this);
|
|
@override
|
|
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
@override
|
|
List<DatabaseSchemaEntity> get allSchemaEntities => [todos];
|
|
@override
|
|
int get schemaVersion => 2;
|
|
}
|