Created
June 16, 2019 14:33
-
-
Save enginebai/967be8efb04c0b02c13bab62321bffa6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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