add "reading" filter for books currently being read
This commit is contained in:
@@ -97,11 +97,32 @@ func FetchReadUserBookCount(db *gorm.DB, userId uint) (int64, error) {
|
||||
return count, res.Error
|
||||
}
|
||||
|
||||
func FetchReadingUserBook(db *gorm.DB, userId uint, limit int, offset int) ([]BookUserGet, error) {
|
||||
var books []BookUserGet
|
||||
query := fetchReadingUserBookQuery(db, userId)
|
||||
query = query.Limit(limit)
|
||||
query = query.Offset(offset)
|
||||
res := query.Find(&books)
|
||||
return books, res.Error
|
||||
}
|
||||
|
||||
func FetchReadingUserBookCount(db *gorm.DB, userId uint) (int64, error) {
|
||||
query := fetchReadingUserBookQuery(db, userId)
|
||||
var count int64
|
||||
res := query.Count(&count)
|
||||
return count, res.Error
|
||||
}
|
||||
|
||||
func fetchReadUserBookQuery(db *gorm.DB, userId uint) *gorm.DB {
|
||||
query := fetchUserBookGet(db, userId)
|
||||
query = query.Where("user_books.read IS TRUE")
|
||||
return query
|
||||
}
|
||||
func fetchReadingUserBookQuery(db *gorm.DB, userId uint) *gorm.DB {
|
||||
query := fetchUserBookGet(db, userId)
|
||||
query = query.Where("user_books.start_read_date IS NOT NULL")
|
||||
return query
|
||||
}
|
||||
|
||||
func FetchWantReadUserBook(db *gorm.DB, userId uint, limit int, offset int) ([]BookUserGet, error) {
|
||||
var books []BookUserGet
|
||||
|
||||
Reference in New Issue
Block a user