Skip to content

Instantly share code, notes, and snippets.

@aleweichandt
Created August 16, 2021 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleweichandt/16b0000416a5cf44fb75d2f3a5816b31 to your computer and use it in GitHub Desktop.
Save aleweichandt/16b0000416a5cf44fb75d2f3a5816b31 to your computer and use it in GitHub Desktop.
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