afterSave method Null safety
- RunFile instance,
- {required SqliteProvider provider,
- ModelRepository<
SqliteModel> ? repository}
override
Hook invoked after the model is successfully entered in the SQLite database.
Useful to update or save associations. This is invoked before
SqliteModel#afterSave
.
Implementation
@override
Future<void> afterSave(instance, {required provider, repository}) async {
if (instance.primaryKey != null) {
await Future.wait<int?>(instance.splitTimes.map((s) async {
final id = s.primaryKey ??
await provider.upsert<SplitTime>(s, repository: repository);
return await provider.rawInsert(
'INSERT OR IGNORE INTO `_brick_RunFile_split_times` (`l_RunFile_brick_id`, `f_SplitTime_brick_id`) VALUES (?, ?)',
[instance.primaryKey, id]);
}));
}
if (instance.primaryKey != null) {
await Future.wait<int?>(instance.locations.map((s) async {
final id = s.primaryKey ??
await provider.upsert<RunLocation>(s, repository: repository);
return await provider.rawInsert(
'INSERT OR IGNORE INTO `_brick_RunFile_locations` (`l_RunFile_brick_id`, `f_RunLocation_brick_id`) VALUES (?, ?)',
[instance.primaryKey, id]);
}));
}
}