diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/db.go | 13 |
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 +} |