Add a new tab to browse all books on the instance
This commit is contained in:
@@ -103,6 +103,22 @@ func fetchUserBookGet(db *gorm.DB, userId uint) *gorm.DB {
|
||||
return query
|
||||
}
|
||||
|
||||
func FetchAllBooks(db *gorm.DB, userId uint, limit int, offset int) ([]dto.BookSearchGetBook, error) {
|
||||
var books []dto.BookSearchGetBook
|
||||
query := fetchBookQueryBuilder(db, userId)
|
||||
query = query.Limit(limit)
|
||||
query = query.Offset(offset)
|
||||
res := query.Find(&books)
|
||||
return books, res.Error
|
||||
}
|
||||
|
||||
func FetchAllBooksCount(db *gorm.DB, userId uint) (int64, error) {
|
||||
var count int64
|
||||
query := fetchBookQueryBuilder(db, userId)
|
||||
res := query.Count(&count)
|
||||
return count, res.Error
|
||||
}
|
||||
|
||||
func FetchBookSearchByAuthorGet(db *gorm.DB, userId uint, authorId uint64, limit int, offset int) ([]dto.BookSearchGetBook, error) {
|
||||
var books []dto.BookSearchGetBook
|
||||
query := fetchBookSearchByAuthorQuery(db, userId, authorId)
|
||||
|
||||
Reference in New Issue
Block a user