import 'package:ambito/src/domain/entity/entities.dart';
import 'package:isar/isar.dart';

import '../../../main.dart';

abstract class BaseDB {
  abstract IsarCollection collection;

  put(BaseEntity entity) {
    isar.write((isar) {
      collection.put(entity);
    });
  }

  putAll(List<BaseEntity> entities) {
    isar.write((isar) {
      collection.putAll(entities);
    });
  }

  get(int id) {
    return collection.get(id);
  }

  List<dynamic> getAll() {
    return collection.where().findAll();
  }
}
