-
Hi! I'm trying to refactor my code and I'm in the process of refactoring my batch functions, insert & delete works without any issues but I've stumble upon an issue when it comes to using
Usage: batch.updateBatch(folders, folderUpdate, (t) => t.id.equals(folderId)); The issue being that since I'm taking in a Table, I assume that Implementation: void updateBatch(TableInfo table, List<Insertable> rows,
Expression<bool> Function(Table) where) async {
await _db.batch((batch) async {
for (final row in rows) {
batch.update(table, row, where: where);
}
});
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Exactly! void updateBatch<T extends Table, D>(TableInfo<T, D> table, List<Insertable<D>> rows,
Expression<bool> Function(T table) where) async {
await _db.batch((batch) async {
for (final row in rows) {
batch.update(table, row, where: where);
}
});
} |
Beta Was this translation helpful? Give feedback.
Exactly!
where
doesn't have that information available statically, which is required for the field to be available. This should work if you makeupdateBatch
generic over the table: