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

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

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

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(vararg authors: AuthorDbo)
}