Created
June 16, 2019 14:27
-
-
Save enginebai/47b41da666273c537d2a196c27ced28c to your computer and use it in GitHub Desktop.
This file contains 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
interface PostApiService { | |
@GET("/feed") | |
fun getFeed(): Single<Response<List<Post>>> | |
} | |
@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(): Observable<List<Post>> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment