package com.paperapp.lenscape.element

import androidx.lifecycle.LiveData

class ElementRepository(private val elementDao: ElementDao) {
    suspend fun allElement():List<Element>{
        return elementDao.getAllElements()
    }
    suspend fun updateElement(element: Element){
    elementDao.update(element)
    }
    suspend fun getElementById(id:String):Element?{
        return elementDao.getById(id)
    }
    suspend fun getClassificationCover(name:String):List<Element>{
        return elementDao.queryCover(name)
    }
    suspend fun getElementByClassification(name: String):List<Element>{
        return elementDao.queryEachGenera(name)
    }
    fun getLikes():LiveData<List<Element>>{
        return elementDao.queryLikeElement()
    }
    suspend fun searchByKey(key:String):List<Element>{
        return elementDao.search(key)
    }
    suspend fun isLike(id: String): Boolean = elementDao.queryIsLike(id) != null
}