Skip to content

Instantly share code, notes, and snippets.

@enginebai

enginebai/NewPostDao.kt

Last active Apr 3, 2019
Embed
What would you like to do?
@Dao
interface NewPostDao {
@Query("SELECT * FROM `new_post`")
fun getAll(): Observable<List<NewPost>>
@Query("SELECT * FROM `new_post` WHERE `id` = :id")
fun getPostById(id: String): Observable<NewPost>
@Insert(onConflict = OnConflictStrategy.IGNORE)
fun insertNewPost(newPost: NewPost): Long
@Update(onConflict = OnConflictStrategy.REPLACE)
fun updateNewPost(newPost: NewPost)
@Delete
fun deleteNewPost(newPost: NewPost)
@Transaction
fun upsert(newPost: NewPost) {
if (-1L == insertNewPost(newPost)) {
updateNewPost(newPost)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.