summaryrefslogtreecommitdiff
path: root/storage/storage.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2024-11-20 20:47:49 +0300
committerGrail Finder <wohilas@gmail.com>2024-11-20 20:47:49 +0300
commit5ccad20bd680dc443b30f0decc8fca13427dc70d (patch)
tree5ed20ce680c09609a29f880cf41c976301f3e031 /storage/storage.go
parentfc517c2c69d96501f1adc5a021b39b9eff22e4d7 (diff)
Feat: add memory [wip]
Diffstat (limited to 'storage/storage.go')
-rw-r--r--storage/storage.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/storage/storage.go b/storage/storage.go
index edbd393..67b8dd8 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -23,26 +23,26 @@ type ProviderSQL struct {
func (p ProviderSQL) ListChats() ([]models.Chat, error) {
resp := []models.Chat{}
- err := p.db.Select(&resp, "SELECT * FROM chat;")
+ err := p.db.Select(&resp, "SELECT * FROM chats;")
return resp, err
}
func (p ProviderSQL) GetChatByID(id uint32) (*models.Chat, error) {
resp := models.Chat{}
- err := p.db.Get(&resp, "SELECT * FROM chat WHERE id=$1;", id)
+ err := p.db.Get(&resp, "SELECT * FROM chats WHERE id=$1;", id)
return &resp, err
}
func (p ProviderSQL) GetLastChat() (*models.Chat, error) {
resp := models.Chat{}
- err := p.db.Get(&resp, "SELECT * FROM chat ORDER BY updated_at DESC LIMIT 1")
+ err := p.db.Get(&resp, "SELECT * FROM chats ORDER BY updated_at DESC LIMIT 1")
return &resp, err
}
func (p ProviderSQL) UpsertChat(chat *models.Chat) (*models.Chat, error) {
// Prepare the SQL statement
query := `
- INSERT OR REPLACE INTO chat (id, name, msgs, created_at, updated_at)
+ INSERT OR REPLACE INTO chats (id, name, msgs, created_at, updated_at)
VALUES (:id, :name, :msgs, :created_at, :updated_at)
RETURNING *;`
stmt, err := p.db.PrepareNamed(query)
@@ -56,7 +56,7 @@ func (p ProviderSQL) UpsertChat(chat *models.Chat) (*models.Chat, error) {
}
func (p ProviderSQL) RemoveChat(id uint32) error {
- query := "DELETE FROM chat WHERE ID = $1;"
+ query := "DELETE FROM chats WHERE ID = $1;"
_, err := p.db.Exec(query, id)
return err
}