Skip to content

Instantly share code, notes, and snippets.

@enginebai
Created June 16, 2019 14:33
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 enginebai/967be8efb04c0b02c13bab62321bffa6 to your computer and use it in GitHub Desktop.
Save enginebai/967be8efb04c0b02c13bab62321bffa6 to your computer and use it in GitHub Desktop.
@Dao
interface PostDao {
@Insert(onConflict = OnConflictStrategy.IGNORE)
fun insert(post: Post): Long
@Update(onConflict = OnConflictStrategy.REPLACE)
fun update(post: Post)
@Transaction
fun upsert(post: Post) {
if (-1L == insert(post))
update(post)
}
@Query("SELECT * FROM `post`")
fun getPostList(): DataSource.Factory<Int, Post>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment