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.GenreDbo

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

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

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(vararg genres: GenreDbo)
}