2020-09-10 21:05:11 +00:00
|
|
|
package oppen.gem.io.bookmarks
|
2020-09-07 21:15:18 +00:00
|
|
|
|
|
|
|
import androidx.room.*
|
|
|
|
|
|
|
|
@Dao
|
|
|
|
interface BookmarksDao {
|
2020-09-11 21:02:54 +00:00
|
|
|
@Query("SELECT * FROM bookmarks ORDER BY uiIndex ASC")
|
2020-09-07 21:15:18 +00:00
|
|
|
suspend fun getAll(): List<BookmarkEntity>
|
|
|
|
|
2020-09-11 21:02:54 +00:00
|
|
|
@Query("SELECT * from bookmarks WHERE uiIndex = :index LIMIT 1")
|
|
|
|
suspend fun getBookmark(index: Int): BookmarkEntity
|
|
|
|
|
2020-09-07 21:15:18 +00:00
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
|
|
|
suspend fun insertAll(vararg bookmarks: BookmarkEntity)
|
|
|
|
|
2020-09-11 21:02:54 +00:00
|
|
|
@Query("UPDATE bookmarks SET uiIndex=:index WHERE uid = :id")
|
|
|
|
fun update(id: Int, index: Int)
|
|
|
|
|
2020-09-07 21:15:18 +00:00
|
|
|
@Delete
|
|
|
|
suspend fun delete(bookmark: BookmarkEntity)
|
|
|
|
}
|