Skip to content

Instantly share code, notes, and snippets.

@lomza
Last active June 2, 2020 13:14
Show Gist options
  • Save lomza/50a94f9a74856f2892260f0ac3425e45 to your computer and use it in GitHub Desktop.
Save lomza/50a94f9a74856f2892260f0ac3425e45 to your computer and use it in GitHub Desktop.
MovieDao.kt
@Dao
interface MovieDao {
@Query("SELECT * FROM movie WHERE title = :title LIMIT 1")
suspend fun findMovieByTitle(title: String?): Movie?
@Insert(onConflict = OnConflictStrategy.IGNORE)
suspend fun insert(vararg directors: Movie)
@Update(onConflict = OnConflictStrategy.IGNORE)
suspend fun update(director: Movie)
@Query("DELETE FROM movie")
suspend fun deleteAll()
@get:Query("SELECT * FROM movie ORDER BY title ASC")
val allMovies: LiveData<List<Movie>>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment