-
-
Save aleweichandt/16b0000416a5cf44fb75d2f3a5816b31 to your computer and use it in GitHub Desktop.
Dao example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Dao | |
interface TodoDao : BaseDao<TodoEntity> { | |
@Query("SELECT * from todo") | |
suspend fun getAll(): Array<TodoEntity> | |
@Query("SELECT * from todo WHERE :uuid = uuid") | |
suspend fun getById(uuid: Long): TodoEntity? | |
@Query("DELETE from todo") | |
suspend fun deleteAll() | |
} | |
@Transaction | |
suspend fun TodoDao.replaceAll(vararg todos: TodoEntity) { | |
deleteAll() | |
insert(*todos) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment