From f12ce11b7fe07d3ebc74e0bb4780502f8f4f54ce Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 14 May 2023 03:38:17 +0400 Subject: [PATCH] Oh, replaced SQLiteMindflow with Mindflow interface. --- internal/http/api_handlers.go | 5 ++--- pkg/mindflow/database/sqlite/db.go | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/http/api_handlers.go b/internal/http/api_handlers.go index 9cafcc6..a921091 100644 --- a/internal/http/api_handlers.go +++ b/internal/http/api_handlers.go @@ -9,7 +9,6 @@ import ( "time" "git.arav.su/Arav/dwelling-home/pkg/mindflow" - "git.arav.su/Arav/dwelling-home/pkg/mindflow/database/sqlite" "git.arav.su/Arav/justcaptcha/pkg/captcha" "git.arav.su/Arav/justcaptcha/pkg/captcha/inmemdb" "git.arav.su/Arav/justcaptcha/pkg/dwcaptcha" @@ -214,10 +213,10 @@ func (h *CaptchaApiHandlers) Image(w http.ResponseWriter, r *http.Request) { // Mindflow API //////////////////////////////////////////////////////////////// type MindflowApiHandlers struct { - db *sqlite.SQLiteMindflow + db mindflow.Mindflow } -func NewMindflowApiHandlers(db *sqlite.SQLiteMindflow) *MindflowApiHandlers { +func NewMindflowApiHandlers(db mindflow.Mindflow) *MindflowApiHandlers { return &MindflowApiHandlers{db: db} } diff --git a/pkg/mindflow/database/sqlite/db.go b/pkg/mindflow/database/sqlite/db.go index 7fac033..b73f1be 100644 --- a/pkg/mindflow/database/sqlite/db.go +++ b/pkg/mindflow/database/sqlite/db.go @@ -82,7 +82,7 @@ type SQLiteMindflow struct { db *sql.DB } -func NewSQLiteMindflow(path string) (*SQLiteMindflow, error) { +func NewSQLiteMindflow(path string) (mindflow.Mindflow, error) { db, err := sql.Open("sqlite3", dsn(path)) if err != nil { return nil, err @@ -121,7 +121,7 @@ func (s *SQLiteMindflow) New(post *mindflow.Post) error { return nil } -func (s *SQLiteMindflow) Edit(post mindflow.Post) error { +func (s *SQLiteMindflow) Edit(post *mindflow.Post) error { tx, err := s.db.Begin() if err != nil { return err