1
0
Fork 0

Implemented NewCategory() method.

This commit is contained in:
Alexander Andreev 2023-05-14 03:52:07 +04:00
parent 83720a317e
commit 5ef41d5961
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 26 additions and 0 deletions

View File

@ -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
}