mirror of https://github.com/AMT-Cheif/drift.git
Use companions in custom row classes
This commit is contained in:
parent
df7f1fb051
commit
eb5196e9e8
|
@ -69,11 +69,11 @@ class User implements Insertable<User> {
|
|||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
return {
|
||||
'id': Variable<int>(id),
|
||||
'name': Variable<String>(name),
|
||||
'birth_date': Variable<DateTime>(birthDate),
|
||||
};
|
||||
return UsersCompanion(
|
||||
id: Value(id),
|
||||
name: Value(name),
|
||||
birthDate: Value(birthDate),
|
||||
).toColumns(nullToAbsent);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
@ -80,11 +80,11 @@ class CustomRowClass implements Insertable<CustomRowClass> {
|
|||
|
||||
@override
|
||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||
return {
|
||||
'not_really_an_id': Variable<int>(notReallyAnId),
|
||||
'some_float': Variable<double>(anotherName),
|
||||
'custom': Variable<String?>(const CustomConverter().mapToSql(custom))
|
||||
};
|
||||
return TableWithoutPKCompanion(
|
||||
notReallyAnId: Value(notReallyAnId),
|
||||
someFloat: Value(anotherName),
|
||||
custom: Value(custom),
|
||||
).toColumns(nullToAbsent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue