37 lines
1.1 KiB
Kotlin
37 lines
1.1 KiB
Kotlin
package chats.data.local.dao
|
|
|
|
import androidx.room.*
|
|
import chats.data.local.database.UserProfileEntity
|
|
import kotlinx.coroutines.flow.Flow
|
|
|
|
/**
|
|
* DAO для операций с профилями пользователей в Room Database
|
|
*/
|
|
@Dao
|
|
interface UserProfileDao {
|
|
|
|
@Query("SELECT * FROM user_profile WHERE userId = :userId LIMIT 1")
|
|
suspend fun getUserById(userId: String): UserProfileEntity?
|
|
|
|
@Query("SELECT * FROM user_profile WHERE userId = :userId")
|
|
fun getUserByIdFlow(userId: String): Flow<UserProfileEntity?>
|
|
|
|
@Query("SELECT * FROM user_profile")
|
|
fun getAllUsers(): Flow<List<UserProfileEntity>>
|
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
|
suspend fun insertUser(user: UserProfileEntity)
|
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
|
suspend fun insertUsers(users: List<UserProfileEntity>)
|
|
|
|
@Update
|
|
suspend fun updateUser(user: UserProfileEntity)
|
|
|
|
@Delete
|
|
suspend fun deleteUser(user: UserProfileEntity)
|
|
|
|
@Query("DELETE FROM user_profile WHERE userId = :userId")
|
|
suspend fun deleteUserById(userId: String)
|
|
}
|