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

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

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

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(vararg series: SeriesDbo)
}