package com.example.myapplication.database.entities.repository

import com.example.myapplication.database.entities.dao.ItemDao
import com.example.myapplication.database.entities.model.Item

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()
}