Coverage Summary for Class: SearchLocalDataSource (clean.architecture.data.search.local)
Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
SearchLocalDataSource |
100%
(1/1)
|
100%
(3/3)
|
|
100%
(4/4)
|
100%
(20/20)
|
package clean.architecture.data.search.local
import clean.architecture.data.db.dao.SearchDao
import clean.architecture.data.db.entity.SearchEntity
import javax.inject.Inject
import javax.inject.Singleton
/**
* Local data source to save search history to the local database.
*/
@Singleton
class SearchLocalDataSource @Inject constructor(
private val searchDao: SearchDao
) {
/**
* Get search history entity from the local database.
*
* @param text The search text.
*/
suspend fun getSearch(text: String): SearchEntity? {
return searchDao.getByText(text)
}
/**
* Save search data to the database.
*
* @param searchEntity The [SearchEntity] to be saved.
*/
suspend fun saveSearch(searchEntity: SearchEntity) {
searchDao.insert(searchEntity)
}
}