updateAll method

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

更新所有数据库

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);
}