diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/common/database/dao/EventSearchHistoryDao.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/common/database/dao/EventSearchHistoryDao.kt index f19ae9610..e9b2b6b7a 100644 --- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/common/database/dao/EventSearchHistoryDao.kt +++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/common/database/dao/EventSearchHistoryDao.kt @@ -17,6 +17,9 @@ interface EventSearchHistoryDao { @Delete fun delete(eventSearch: EventSearchHistoryEntity) + @Query("DELETE FROM event_search WHERE query = :query") + fun deleteByQuery(query: String) + @Query("DELETE FROM event_search") fun deleteAll() } diff --git a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultEventSearchRepository.kt b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultEventSearchRepository.kt index f3b615f45..ff0c711cc 100644 --- a/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultEventSearchRepository.kt +++ b/android/2023-emmsale/app/src/main/java/com/emmsale/data/repository/concretes/DefaultEventSearchRepository.kt @@ -23,6 +23,7 @@ class DefaultEventSearchRepository @Inject constructor( override suspend fun save(searchQuery: String) { withContext(dispatcher) { + dao.deleteByQuery(searchQuery) dao.save(EventSearchHistoryEntity(query = searchQuery)) } }