Skip to content

Instantly share code, notes, and snippets.

@vRallev
Created Oct 24, 2017
Embed
What would you like to do?
@Dao
interface NoteDao {
@Insert(onConflict = OnConflictStrategy.ABORT)
fun insert(note: Note): Long
@Update(onConflict = OnConflictStrategy.ABORT)
fun update(note: Note): Int
@Query("SELECT * FROM notes")
fun observeAllNotes(): Flowable<Note>
@Query("SELECT * FROM notes WHERE id = :id")
fun findById(id: Long): Note
}
class NoteDaoHelper internal constructor(private val noteDao: NoteDao) : NoteDao by noteDao {
fun updateAndReturnNewValue(note: Note): Note {
update(note)
return findById(note.id)
}
override fun observeAllNotes(): Flowable<Note> {
return noteDao.observeAllNotes().subscribeOn(Schedulers.io())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment