summaryrefslogtreecommitdiff
path: root/models/db.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2024-11-20 06:51:40 +0300
committerGrail Finder <wohilas@gmail.com>2024-11-20 06:51:40 +0300
commitaaf056663628f15bb6e4f23c899b6fd31bac5bf7 (patch)
treea0129fbb531e31d1a9d6465549a44b823906aaae /models/db.go
parentf32375488f5127c910021f627d83e017c5c7a10f (diff)
Enha: db chat management
Diffstat (limited to 'models/db.go')
-rw-r--r--models/db.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/models/db.go b/models/db.go
index 24bef41..afd4b46 100644
--- a/models/db.go
+++ b/models/db.go
@@ -1,6 +1,9 @@
package models
-import "time"
+import (
+ "encoding/json"
+ "time"
+)
type Chat struct {
ID uint32 `db:"id" json:"id"`
@@ -9,3 +12,11 @@ type Chat struct {
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
+
+func (c Chat) ToHistory() ([]MessagesStory, error) {
+ resp := []MessagesStory{}
+ if err := json.Unmarshal([]byte(c.Msgs), &resp); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}