update method

Future<List<UserModel>> update(
  1. List<UserModel> models
)

Update list users

Implementation

Future<List<UserModel>> update(List<UserModel> models) async {
  await _db.transaction(() async {
    for (final model in models) {
      await (_db.update(_db.users)..where((row) => row.id.equals(model.id!)))
          .write(model.toCompanion());
    }
  });
  return (_db.select(_db.users)
        ..where((tbl) => tbl.id.isIn(models.map((e) => e.id!))))
      .get();
}