Implemented NewCategory() method.
This commit is contained in:
parent
83720a317e
commit
5ef41d5961
@ -182,3 +182,29 @@ func (s *SQLiteMindflow) GetAll() (posts []mindflow.Post, err error) {
|
||||
defer tx.Rollback()
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *SQLiteMindflow) NewCategory(name string) (int64, error) {
|
||||
tx, err := s.db.Begin()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
r, err := tx.Stmt(stmtPostNew).Exec(name)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
id, err := r.LastInsertId()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (s *SQLiteMindflow) GetCategoryByID(id int64) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user