add limit to index page, for performance improvements
This commit is contained in:
@@ -11,13 +11,14 @@ type ArticleModel struct {
|
||||
|
||||
// Gets all the article objects from the database. This may throw an error if
|
||||
// the connection to the database fails.
|
||||
func (m *ArticleModel) All() ([]model.Article, error) {
|
||||
func (m *ArticleModel) All(limit int) ([]model.Article, error) {
|
||||
stmt := `
|
||||
SELECT id, title, sourceUrl, author, content, publishDate, fetchDate
|
||||
FROM articles
|
||||
ORDER BY publishDate DESC
|
||||
LIMIT $1
|
||||
`
|
||||
rows, err := m.DB.Query(stmt)
|
||||
rows, err := m.DB.Query(stmt, limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user