ariane/app/src/main/java/oppen/ariane/io/database/bookmarks/BookmarksDao.kt

24 lines
751 B
Kotlin
Raw Normal View History

package oppen.ariane.io.database.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 updateUIIndex(id: Int, index: Int)
@Query("UPDATE bookmarks SET label=:label, uri=:uri WHERE uid = :id")
fun updateContent(id: Int, label: String, uri: String)
2020-09-11 21:02:54 +00:00
2020-09-07 21:15:18 +00:00
@Delete
suspend fun delete(bookmark: BookmarkEntity)
}