import 'package:ambito/src/entity/area/area.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';

import '../../consts/consts.dart';

class AreaRepository extends BaseDB {
  @override
  IsarCollection collection = isar.areas;

  List<Area> getAreasForBusiness(int id) {
    final all = isar.areas.where().findAll();
    List<Area> areas = [];
    for (final Area area in all) {
      if (area.business!.any((ele) => ele.id == id)) {
        areas.add(area);
      }
    }
    return areas;
  }
}
