insertAll method

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

插入所有model

Implementation

@override
Future<int> insertAll(List<T?> t, {
  String? tableName,
  String? nullColumnHack,
  ConflictAlgorithm? conflictAlgorithm = ConflictAlgorithm.replace,
}) async {
  final batch = db.batch();
  for (T? c in t) {
    if (c == null) continue;
    Map<String, dynamic> values = c.toJson();
    _convertSafeMap(values);
    batch.insert(
      tableName ?? table,
      values,
      nullColumnHack: nullColumnHack,
      conflictAlgorithm: conflictAlgorithm,
    );
  }
  await batch.commit(noResult: true);
  return Future.value(0);
}