Skip to content

Instantly share code, notes, and snippets.

@aleweichandt
Created Aug 16, 2021
Embed
What would you like to do?
Dao example
@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