Put Categories() down under the New*, Edit*, and DeleteCategory methods.
This commit is contained in:
parent
ca51617f0e
commit
d18374e72a
@ -201,34 +201,6 @@ func (s *SQLiteMindflow) Posts() (posts []mindflow.Post, err error) {
|
||||
return posts, nil
|
||||
}
|
||||
|
||||
func (s *SQLiteMindflow) Categories() (categories []mindflow.Category, err error) {
|
||||
tx, err := s.db.Begin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
rows, err := tx.Stmt(stmtCategoryGetAll).Query()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var category mindflow.Category
|
||||
|
||||
if err = rows.Scan(&category.ID, &category.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
categories = append(categories, category)
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
||||
return categories, nil
|
||||
}
|
||||
|
||||
func (s *SQLiteMindflow) NewCategory(category *mindflow.Category) (int64, error) {
|
||||
tx, err := s.db.Begin()
|
||||
if err != nil {
|
||||
@ -284,6 +256,34 @@ func (s *SQLiteMindflow) DeleteCategory(id int64) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SQLiteMindflow) Categories() (categories []mindflow.Category, err error) {
|
||||
tx, err := s.db.Begin()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
rows, err := tx.Stmt(stmtCategoryGetAll).Query()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var category mindflow.Category
|
||||
|
||||
if err = rows.Scan(&category.ID, &category.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
categories = append(categories, category)
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
||||
return categories, nil
|
||||
}
|
||||
|
||||
func (s *SQLiteMindflow) Close() error {
|
||||
stmtCategoryGetAll.Close()
|
||||
stmtCategoryNew.Close()
|
||||
|
Loading…
Reference in New Issue
Block a user