Skip to content

Commit

Permalink
fix: lectures database serialization (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
limwa authored Sep 12, 2024
2 parents 91a100b + fa3f3be commit 947fb41
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ class AppLecturesDatabase extends AppDatabase<List<Lecture>> {
createScript,
],
onUpgrade: migrate,
version: 9,
version: 10,
);
static const createScript = '''
CREATE TABLE lectures(subject TEXT, typeClass TEXT,
startTime TEXT, endTime TEXT, blocks INTEGER, room TEXT, teacher TEXT, classNumber TEXT, occurrId INTEGER)''';
startTime TEXT, endTime TEXT, room TEXT, teacher TEXT, classNumber TEXT, occurrId INTEGER)''';

/// Returns a list containing all of the lectures stored in this database.
Future<List<Lecture>> lectures() async {
final db = await getDatabase();
final List<Map<String, dynamic>> maps = await db.query('lectures');

return List.generate(maps.length, (i) {
return Lecture.fromApi(
return Lecture(
maps[i]['subject'] as String,
maps[i]['typeClass'] as String,
DateTime.parse(maps[i]['startTime'] as String),
maps[i]['blocks'] as int,
DateTime.parse(maps[i]['endTime'] as String),
maps[i]['room'] as String,
maps[i]['teacher'] as String,
maps[i]['classNumber'] as String,
Expand Down

0 comments on commit 947fb41

Please sign in to comment.