diff --git a/app/src/main/kotlin/com/looker/droidify/data/local/dao/RepoDao.kt b/app/src/main/kotlin/com/looker/droidify/data/local/dao/RepoDao.kt index ebc01227..1d36928c 100644 --- a/app/src/main/kotlin/com/looker/droidify/data/local/dao/RepoDao.kt +++ b/app/src/main/kotlin/com/looker/droidify/data/local/dao/RepoDao.kt @@ -2,20 +2,19 @@ package com.looker.droidify.data.local.dao import androidx.room.Dao import androidx.room.Query -import androidx.room.Transaction +import com.looker.droidify.data.local.model.RepoEntity +import kotlinx.coroutines.flow.Flow @Dao interface RepoDao { + @Query("SELECT * FROM repository") + fun stream(): Flow> + + @Query("SELECT * FROM repository WHERE id = :repoId") + fun repo(repoId: Int): Flow + @Query("DELETE FROM repository WHERE id = :id") suspend fun delete(id: Int) - @Query("DELETE FROM authentication WHERE repoId = :repoId") - suspend fun deleteAuth(repoId: Int) - - @Transaction - suspend fun deleteRepo(repoId: Int) { - delete(repoId) - deleteAuth(repoId) - } } diff --git a/app/src/main/kotlin/com/looker/droidify/data/local/model/AuthenticationEntity.kt b/app/src/main/kotlin/com/looker/droidify/data/local/model/AuthenticationEntity.kt index d1eeaa34..5d6cb792 100644 --- a/app/src/main/kotlin/com/looker/droidify/data/local/model/AuthenticationEntity.kt +++ b/app/src/main/kotlin/com/looker/droidify/data/local/model/AuthenticationEntity.kt @@ -2,6 +2,7 @@ package com.looker.droidify.data.local.model import androidx.room.Entity import androidx.room.ForeignKey +import androidx.room.ForeignKey.Companion.CASCADE import androidx.room.PrimaryKey import com.looker.droidify.data.encryption.Encrypted @@ -12,8 +13,7 @@ import com.looker.droidify.data.encryption.Encrypted entity = RepoEntity::class, childColumns = ["repoId"], parentColumns = ["id"], -// Handles in dao -// onDelete = CASCADE, + onDelete = CASCADE, ), ], )