package com.example.myapplication.database.room.repository.offline

import com.example.myapplication.database.room.dao.item.ItemDao
import com.example.myapplication.database.room.model.item.Item
import com.example.myapplication.database.room.repository.online.ItemRepository

class OfflineItemRepository(private val itemDao: ItemDao) : ItemRepository {
    override suspend fun getItem(uid: Int): Item = itemDao.getByUid(uid)

    override suspend fun insertItem(item: Item) = itemDao.insert(item)

    override suspend fun updateItem(item: Item) = itemDao.update(item)

    override suspend fun deleteItem(item: Item) = itemDao.delete(item)

    suspend fun insertItems(items: List<Item>) =
        itemDao.insert(*items.toTypedArray())

    suspend fun clearItems() = itemDao.deleteAll()
}