Replies: 2 comments
-
The example assumes that you're using the json_serializable package to generate these methods. class AssignmentsEntries
{
final List<String> assignments;
AssignmentsEntries({required this.assignments});
factory AssignmentsEntries.fromJson(List<dynamic> json) => AssignmentEntries(assignments: json.cast());
List<String> toJson() => assignments;
static JsonTypeConverter<AssignmentsEntries, String> converter =
TypeConverter.json(
fromJson: (json) => AssignmentsEntries.fromJson(json as List<dynamic>),
toJson: (entries) => entries.toJson(),
);
}
Snippets posted on the documentation website are written in Dart files so that they can be unit tested and analyzed. That way I remember to update them after a breaking change in drift.
The |
Beta Was this translation helpful? Give feedback.
-
Hello Simolus3, Thank you for your help and feedback. This requirement of adding assignements/tags in my object was little headhache for me. If working with database field that contains many simple value separate by coma is not so heavy for requesting with Drift in many context, I think starting with this solution. (Eq : "foo, bar, team" <---> List). Hence, I created so simple TypeConverter and Object for doing this and I think that I work. This is my example code :
When I try to persist data, the "toSql" function seems to be working good.
The "toto" value (then the "fromSql" function of AssignmentsConverter) is only viewable into "_parsedData" variable of result var of request but I never work with this parsedData and I don't know how to work with (and if it's the good way) ? Can you enlighting me about this and if I on the good way for working with my converter ? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everybody Drifters,
In context of application with Drift package, I need to declare Many To Many relationship between an Operations and theirs Assignments.
One Operation can have Many Assignments AND Assignment can be include into Many Operations.
Assignments are just a String text variable...
In my Operations Table class I have this field :
In the same table class file I have created new class like this :
Questions :
_$AssignmentsEntriesFromJson
function and where do it from ? Because it does not recognize in my editorThank you for your enlighning !
Beta Was this translation helpful? Give feedback.
All reactions