29 lines
863 B
Kotlin
29 lines
863 B
Kotlin
package agzam.vyatsu.data.local
|
|
|
|
import androidx.room.Dao
|
|
import androidx.room.Insert
|
|
import androidx.room.OnConflictStrategy
|
|
import androidx.room.Query
|
|
import kotlinx.coroutines.flow.Flow
|
|
|
|
@Dao
|
|
interface GroupDao {
|
|
@Query("SELECT * FROM groups ORDER BY name")
|
|
fun observeAll(): Flow<List<GroupEntity>>
|
|
|
|
@Query("SELECT * FROM groups WHERE id = :id")
|
|
suspend fun getById(id: String): GroupEntity?
|
|
|
|
@Query("SELECT * FROM groups WHERE faculty = :faculty ORDER BY name")
|
|
suspend fun getByFaculty(faculty: String): List<GroupEntity>
|
|
|
|
@Query("SELECT DISTINCT faculty FROM groups ORDER BY faculty")
|
|
suspend fun getFaculties(): List<String>
|
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
|
suspend fun insertAll(groups: List<GroupEntity>)
|
|
|
|
@Query("SELECT MAX(lastSyncedAt) FROM groups")
|
|
suspend fun maxSyncedAt(): Long?
|
|
}
|