fnotes/lib/database.g.dart
Marco 10ad73c940 Adding persistence
This commit adds persistence.
Notes are added to a sqlite database, can be deleted and are read at app
start.
2024-03-29 17:14:47 +01:00

198 lines
5.9 KiB
Dart

// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'database.dart';
// ignore_for_file: type=lint
class $NoteTableTable extends NoteTable
with TableInfo<$NoteTableTable, NoteTableData> {
@override
final GeneratedDatabase attachedDatabase;
final String? _alias;
$NoteTableTable(this.attachedDatabase, [this._alias]);
static const VerificationMeta _idMeta = const VerificationMeta('id');
@override
late final GeneratedColumn<String> id = GeneratedColumn<String>(
'id', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true);
static const VerificationMeta _contentMeta =
const VerificationMeta('content');
@override
late final GeneratedColumn<String> content = GeneratedColumn<String>(
'content', aliasedName, false,
type: DriftSqlType.string, requiredDuringInsert: true);
@override
List<GeneratedColumn> get $columns => [id, content];
@override
String get aliasedName => _alias ?? actualTableName;
@override
String get actualTableName => $name;
static const String $name = 'note_table';
@override
VerificationContext validateIntegrity(Insertable<NoteTableData> instance,
{bool isInserting = false}) {
final context = VerificationContext();
final data = instance.toColumns(true);
if (data.containsKey('id')) {
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
} else if (isInserting) {
context.missing(_idMeta);
}
if (data.containsKey('content')) {
context.handle(_contentMeta,
content.isAcceptableOrUnknown(data['content']!, _contentMeta));
} else if (isInserting) {
context.missing(_contentMeta);
}
return context;
}
@override
Set<GeneratedColumn> get $primaryKey => const {};
@override
NoteTableData map(Map<String, dynamic> data, {String? tablePrefix}) {
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
return NoteTableData(
id: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}id'])!,
content: attachedDatabase.typeMapping
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
);
}
@override
$NoteTableTable createAlias(String alias) {
return $NoteTableTable(attachedDatabase, alias);
}
}
class NoteTableData extends DataClass implements Insertable<NoteTableData> {
final String id;
final String content;
const NoteTableData({required this.id, required this.content});
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
map['id'] = Variable<String>(id);
map['content'] = Variable<String>(content);
return map;
}
NoteTableCompanion toCompanion(bool nullToAbsent) {
return NoteTableCompanion(
id: Value(id),
content: Value(content),
);
}
factory NoteTableData.fromJson(Map<String, dynamic> json,
{ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return NoteTableData(
id: serializer.fromJson<String>(json['id']),
content: serializer.fromJson<String>(json['content']),
);
}
@override
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return <String, dynamic>{
'id': serializer.toJson<String>(id),
'content': serializer.toJson<String>(content),
};
}
NoteTableData copyWith({String? id, String? content}) => NoteTableData(
id: id ?? this.id,
content: content ?? this.content,
);
@override
String toString() {
return (StringBuffer('NoteTableData(')
..write('id: $id, ')
..write('content: $content')
..write(')'))
.toString();
}
@override
int get hashCode => Object.hash(id, content);
@override
bool operator ==(Object other) =>
identical(this, other) ||
(other is NoteTableData &&
other.id == this.id &&
other.content == this.content);
}
class NoteTableCompanion extends UpdateCompanion<NoteTableData> {
final Value<String> id;
final Value<String> content;
final Value<int> rowid;
const NoteTableCompanion({
this.id = const Value.absent(),
this.content = const Value.absent(),
this.rowid = const Value.absent(),
});
NoteTableCompanion.insert({
required String id,
required String content,
this.rowid = const Value.absent(),
}) : id = Value(id),
content = Value(content);
static Insertable<NoteTableData> custom({
Expression<String>? id,
Expression<String>? content,
Expression<int>? rowid,
}) {
return RawValuesInsertable({
if (id != null) 'id': id,
if (content != null) 'content': content,
if (rowid != null) 'rowid': rowid,
});
}
NoteTableCompanion copyWith(
{Value<String>? id, Value<String>? content, Value<int>? rowid}) {
return NoteTableCompanion(
id: id ?? this.id,
content: content ?? this.content,
rowid: rowid ?? this.rowid,
);
}
@override
Map<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
if (id.present) {
map['id'] = Variable<String>(id.value);
}
if (content.present) {
map['content'] = Variable<String>(content.value);
}
if (rowid.present) {
map['rowid'] = Variable<int>(rowid.value);
}
return map;
}
@override
String toString() {
return (StringBuffer('NoteTableCompanion(')
..write('id: $id, ')
..write('content: $content, ')
..write('rowid: $rowid')
..write(')'))
.toString();
}
}
abstract class _$AppDatabase extends GeneratedDatabase {
_$AppDatabase(QueryExecutor e) : super(e);
late final $NoteTableTable noteTable = $NoteTableTable(this);
@override
Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@override
List<DatabaseSchemaEntity> get allSchemaEntities => [noteTable];
}