package com.pixelized.biblib.database.dao

import androidx.paging.DataSource
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.pixelized.biblib.database.data.LanguageDbo

@Dao
interface LanguageDao {
    @Query("SELECT * FROM ${LanguageDbo.TABLE} ORDER BY ${LanguageDbo.NAME}")
    fun getAll(): DataSource.Factory<Int, LanguageDbo>

    @Query("SELECT * FROM ${LanguageDbo.TABLE} WHERE ${LanguageDbo.ID} LIKE :id")
    fun get(id: String?): LanguageDbo?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(vararg languages: LanguageDbo)
}