From de09e150b20b8e1fc7123d682b6dfc8ccbcd88c7 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Fri, 25 Dec 2015 09:31:23 -0800 Subject: [PATCH] add paging to db call --- news/news.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/news.go b/news/news.go index 094930d..f120c76 100644 --- a/news/news.go +++ b/news/news.go @@ -94,7 +94,7 @@ func Get(db *sql.DB, id int) (*News, error) { func LoadPage(db *sql.DB, offset, amount int) ([]*News, int, error) { categories.LoadCategories(db) // required by addContainer - rows, err := db.Query("SELECT " + SQL_NEWS_FIELDS + " FROM news order by timestamp DESC") + rows, err := db.Query("SELECT " + SQL_NEWS_FIELDS + " FROM news ORDER BY timestamp DESC LIMIT $1 OFFSET $2", amount, offset) if err != nil { fmt.Println("DB errpr reading LoadPage news: ", err) return nil, 0, err