-
I basically have two tables with a many-to-many relationship based on the Many-To-Many relationships with JSON documentation: class Sessions extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get entries => text().map(SessionGrades.converter)();
}
class Grades extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text()();
IntColumn get points => integer()();
}
@JsonSerializable()
class SessionGrades {
SessionGrades({required this.grades});
factory SessionGrades.fromJson(Map<String, Object?> json) =>
_$SessionGradesFromJson(json);
final List<int> grades;
Map<String, Object?> toJson() => _$SessionGradesToJson(this);
static JsonTypeConverter<SessionGrades, String> converter =
TypeConverter.json(
fromJson: (json) => SessionGrades.fromJson(json as Map<String, Object?>),
toJson: (entries) => entries.toJson(),
);
} And I would like to add a column to the My first thought was to add a column like so: class Sessions extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get entries => text().map(SessionGrades.converter)();
IntColumn get points => integer().generatedAs(/* todo */, stored: true);
} With the Should I create a view? But this would have to recompute the value every time. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Well, it seems like I should have kept on trying the things instead of pondering what the correct thing is for so long. |
Beta Was this translation helpful? Give feedback.
Well, it seems like I should have kept on trying the things instead of pondering what the correct thing is for so long.
I have now created a trigger on the update of the entries and it works just how I wanted it to.