updateAll method

  1. @override
Future<int> updateAll(
  1. List<AvatarModel>? t, {
  2. String? tableName,
  3. ConflictAlgorithm? conflictAlgorithm = ConflictAlgorithm.replace,
})
inherited

更新所有数据库

Implementation

@override
Future<int> updateAll(
  List<T>? t, {
  String? tableName,
  ConflictAlgorithm? conflictAlgorithm = ConflictAlgorithm.replace,
}) async {
  if (t == null || t.isEmpty) return Future.value(-1);
  final _batch = _db.batch();
  for (T? c in t) {
    if (c == null) continue;
    Map<String, dynamic> values = c.toJson();
    Map keyAndValues = c.primaryKeyAndValue();
    _convertSafeMap(values);
    _batch.update(
      tableName ?? table,
      values,
      conflictAlgorithm: conflictAlgorithm,
      where: "${keyAndValues.keys.first} = ?",
      whereArgs: [keyAndValues.values.first],
    );
  }
  await _batch.commit(noResult: true);
  return Future.value(0);
}