import 'package:drift/drift.dart'; import 'package:lensai/features/chat_archive/data/database/database.dart'; part 'search.g.dart'; @DriftAccessor() class SearchDao extends DatabaseAccessor with _$SearchDaoMixin { SearchDao(super.db); Future indexChats(Iterable chats) { return db.chat.insertAll(chats); } Future deleteAllChats() { return db.chat.deleteAll(); } Future deleteChat(String fileName) { return (db.chat.delete()..where((t) => t.fileName.equals(fileName))).go(); } Future upsertChat(ChatCompanion chat) { return db.chat.insertOne( chat, onConflict: DoUpdate( (old) => ChatCompanion.custom( content: Variable(chat.content.value), ), ), ); } Selectable queryChats({ required String matchPrefix, required String matchSuffix, required String ellipsis, required int snippetLength, required String searchString, }) { return db.chatQuery( query: db.buildQuery(searchString), snippetLength: snippetLength, beforeMatch: matchPrefix, afterMatch: matchSuffix, ellipsis: ellipsis, ); } }