mirror of https://github.com/AMT-Cheif/drift.git
Migrate with_built_value to moor/ffi
This commit is contained in:
parent
95f25421b4
commit
599128273c
|
@ -1,6 +1,6 @@
|
|||
import 'package:built_value/built_value.dart';
|
||||
import 'package:moor/moor.dart';
|
||||
import 'package:moor_ffi/moor_ffi.dart';
|
||||
import 'package:moor/ffi.dart';
|
||||
|
||||
part 'database.moor.dart';
|
||||
part 'database.g.dart';
|
||||
|
|
|
@ -33,6 +33,13 @@ class User extends DataClass implements Insertable<User> {
|
|||
return map;
|
||||
}
|
||||
|
||||
UsersCompanion toCompanion(bool nullToAbsent) {
|
||||
return UsersCompanion(
|
||||
id: id == null && nullToAbsent ? const Value.absent() : Value(id),
|
||||
name: name == null && nullToAbsent ? const Value.absent() : Value(name),
|
||||
);
|
||||
}
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json,
|
||||
{ValueSerializer serializer}) {
|
||||
serializer ??= moorRuntimeOptions.defaultSerializer;
|
||||
|
@ -82,6 +89,16 @@ class UsersCompanion extends UpdateCompanion<User> {
|
|||
this.id = const Value.absent(),
|
||||
@required String name,
|
||||
}) : name = Value(name);
|
||||
static Insertable<User> custom({
|
||||
Expression<int> id,
|
||||
Expression<String> name,
|
||||
}) {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (name != null) 'name': name,
|
||||
});
|
||||
}
|
||||
|
||||
UsersCompanion copyWith({Value<int> id, Value<String> name}) {
|
||||
return UsersCompanion(
|
||||
id: id ?? this.id,
|
||||
|
@ -100,6 +117,15 @@ class UsersCompanion extends UpdateCompanion<User> {
|
|||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return (StringBuffer('UsersCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('name: $name')
|
||||
..write(')'))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class Users extends Table with TableInfo<Users, User> {
|
||||
|
|
|
@ -6,8 +6,7 @@ environment:
|
|||
sdk: '>=2.6.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
moor: ^2.3.0
|
||||
moor_ffi: ^0.4.0
|
||||
moor: ^3.2.0
|
||||
built_value: ^7.0.0
|
||||
|
||||
dev_dependencies:
|
||||
|
@ -18,8 +17,6 @@ dev_dependencies:
|
|||
dependency_overrides:
|
||||
moor:
|
||||
path: ../../moor
|
||||
moor_ffi:
|
||||
path: ../../moor_ffi
|
||||
moor_generator:
|
||||
path: ../../moor_generator
|
||||
sqlparser:
|
||||
|
|
Loading…
Reference in New Issue