insertAll method

Future<List<StorageOperator>> insertAll (List<StorageOperator> operators)

Implementation

Future<List<StorageOperator>> insertAll(
    List<StorageOperator> operators) async {
  Database db = await this.db;
  try {
    Batch batch = db.batch();
    operators.forEach((StorageOperator operator) {
      batch.insert(this.tableName, operator.toMap());
    });
    List<int> results = await batch.commit();
    for (int i = 0; i < results.length; i++) {
      operators[i]._id = results[i];
    }
    return operators;
  } catch (e) {
    await this.close();
    throw new Exception(e);
  }
}