diff --git a/drift/lib/src/runtime/manager/manager.dart b/drift/lib/src/runtime/manager/manager.dart index 446e69b7..ba366487 100644 --- a/drift/lib/src/runtime/manager/manager.dart +++ b/drift/lib/src/runtime/manager/manager.dart @@ -564,4 +564,16 @@ abstract class RootTableManager< Future replace(Insertable entity) { return $state.db.update($state._tableAsTableInfo).replace(entity); } + + /// Replace multiple rows in the table + /// + /// If any of the [entities] has an absent value (set to null on the [DataClass] or + /// explicitly to absent on the [UpdateCompanion]), and a default value for + /// the field exists, that default value will be used. Otherwise, the field + /// will be reset to null. This behavior is different to [update], which simply + /// ignores such fields without changing them in the database. + Future bulkReplace(Iterable> entities) { + return $state.db + .batch((b) => b.replaceAll($state._tableAsTableInfo, entities)); + } }