generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
ItemDao.kt
35 lines (30 loc) · 1.08 KB
/
ItemDao.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.bitwarden.authenticator.data.authenticator.datasource.disk.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.bitwarden.authenticator.data.authenticator.datasource.disk.entity.AuthenticatorItemEntity
import kotlinx.coroutines.flow.Flow
/**
* Provides methods for inserting, reading, and deleting authentication items from the database
* using [AuthenticatorItemEntity].
*/
@Dao
interface ItemDao {
/**
* Inserts a single authenticator item into the database.
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(item: AuthenticatorItemEntity)
/**
* Read all authenticator items from the database.
*/
@Query("SELECT * FROM items")
fun getAllItems(): Flow<List<AuthenticatorItemEntity>>
/**
* Deletes the specified authenticator item with the given [itemId]. This will return the number
* of rows deleted by this query.
*/
@Query("DELETE FROM items WHERE id = :itemId")
suspend fun deleteItem(itemId: String): Int
}