deleteMulti method

  1. @override
Future<int> deleteMulti(
  1. List<Object?>? datas, [
  2. String? tableName
])
override

删除多个Id

Implementation

@override
Future<int> deleteMulti(List<Object?>? datas, [String? tableName]) async {
  if (datas is List<T>) {
    final batch = db.batch();
    for (T? c in datas) {
      if (c == null) continue;
      Map map = c.primaryKeyAndValue();
      batch.delete(tableName ?? table, where: "${map.keys.first} = ?", whereArgs: [map.values.first]);
    }
    await batch.commit(noResult: true);
  } else {
    String ids = composeIds(datas);
    String sql = "delete from $table where $_primaryKey in ($ids)";
    try {
      return await db.rawDelete(sql);
    } catch (e) {
      print(e);
    }
  }
  return -1;
}