Add a query to get the next unread chapter

This commit is contained in:
inorichi 2015-11-30 21:08:06 +01:00
parent 665eb232a7
commit 382acab118

View File

@ -226,6 +226,21 @@ public class DatabaseHelper {
.prepare();
}
public PreparedGetListOfObjects<Chapter> getNextUnreadChapter(Manga manga) {
return db.get()
.listOfObjects(Chapter.class)
.withQuery(Query.builder()
.table(ChapterTable.TABLE)
.where(ChapterTable.COLUMN_MANGA_ID + "=? AND " +
ChapterTable.COLUMN_READ + "=? AND " +
ChapterTable.COLUMN_CHAPTER_NUMBER + ">=?")
.whereArgs(manga.id, 0, 0)
.orderBy(ChapterTable.COLUMN_CHAPTER_NUMBER)
.limit(1)
.build())
.prepare();
}
public PreparedPutObject<Chapter> insertChapter(Chapter chapter) {
return db.put()
.object(chapter)