mirror of https://github.com/AMT-Cheif/drift.git
187 lines
5.5 KiB
Dart
187 lines
5.5 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'database.dart';
|
|
|
|
// **************************************************************************
|
|
// DriftDatabaseGenerator
|
|
// **************************************************************************
|
|
|
|
// ignore_for_file: type=lint
|
|
class Note extends DataClass implements Insertable<Note> {
|
|
final int id;
|
|
final String content;
|
|
const Note({required this.id, required this.content});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['content'] = Variable<String>(content);
|
|
return map;
|
|
}
|
|
|
|
NotesCompanion toCompanion(bool nullToAbsent) {
|
|
return NotesCompanion(
|
|
id: Value(id),
|
|
content: Value(content),
|
|
);
|
|
}
|
|
|
|
factory Note.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return Note(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
content: serializer.fromJson<String>(json['content']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'content': serializer.toJson<String>(content),
|
|
};
|
|
}
|
|
|
|
Note copyWith({int? id, String? content}) => Note(
|
|
id: id ?? this.id,
|
|
content: content ?? this.content,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('Note(')
|
|
..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 Note && other.id == this.id && other.content == this.content);
|
|
}
|
|
|
|
class NotesCompanion extends UpdateCompanion<Note> {
|
|
final Value<int> id;
|
|
final Value<String> content;
|
|
const NotesCompanion({
|
|
this.id = const Value.absent(),
|
|
this.content = const Value.absent(),
|
|
});
|
|
NotesCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String content,
|
|
}) : content = Value(content);
|
|
static Insertable<Note> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? content,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (content != null) 'content': content,
|
|
});
|
|
}
|
|
|
|
NotesCompanion copyWith({Value<int>? id, Value<String>? content}) {
|
|
return NotesCompanion(
|
|
id: id ?? this.id,
|
|
content: content ?? this.content,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (content.present) {
|
|
map['content'] = Variable<String>(content.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('NotesCompanion(')
|
|
..write('id: $id, ')
|
|
..write('content: $content')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $NotesTable extends Notes with TableInfo<$NotesTable, Note> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$NotesTable(this.attachedDatabase, [this._alias]);
|
|
final VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'),
|
|
hasAutoIncrement: true);
|
|
final 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 ?? 'notes';
|
|
@override
|
|
String get actualTableName => 'notes';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<Note> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _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 => {id};
|
|
@override
|
|
Note map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return Note(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
content: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$NotesTable createAlias(String alias) {
|
|
return $NotesTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
abstract class _$MyEncryptedDatabase extends GeneratedDatabase {
|
|
_$MyEncryptedDatabase(QueryExecutor e) : super(e);
|
|
late final $NotesTable notes = $NotesTable(this);
|
|
@override
|
|
Iterable<TableInfo<Table, dynamic>> get allTables =>
|
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
@override
|
|
List<DatabaseSchemaEntity> get allSchemaEntities => [notes];
|
|
}
|