Add total to search API

This commit is contained in:
Damillora 2021-07-11 00:48:11 +07:00
parent eb25a333e7
commit 14d04c649f
1 changed files with 2 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import (
type SearchResult struct {
Page int `json:"page"`
PerPage int `json:"per_page"`
Total int `json:"total"`
Result []models.ArticleSearchResult `json:"result"`
}
@ -44,6 +45,7 @@ func SearchArticles(q string, page int) (SearchResult, error) {
return SearchResult{
Page: page,
PerPage: perPage,
Total: searchResult.Found,
Result: articles,
}, nil
}