import 'package:isar/isar.dart';
import 'package:path_provider/path_provider.dart';
import '../../features/chat/data/models/chat_model.dart';
import '../../features/chat/data/models/message_model.dart';

class DatabaseService {
  late Isar _isar;

  Isar get isar => _isar;

  Future<void> init() async {
    final dir = await getApplicationDocumentsDirectory();
    _isar = await Isar.open(
      [ChatModelSchema, MessageModelSchema],
      directory: dir.path,
    );
  }

  Future<void> clearAll() async {
    await _isar.writeTxn(() => _isar.clear());
  }
}
