From 6160b4fdc5f37e4ceaa6b3c5acc855f466049d61 Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Sun, 6 Oct 2024 17:04:37 +0300 Subject: Первая версия MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/model/quote.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pkg/model/quote.go (limited to 'pkg/model') diff --git a/pkg/model/quote.go b/pkg/model/quote.go new file mode 100644 index 0000000..0ad89cf --- /dev/null +++ b/pkg/model/quote.go @@ -0,0 +1,23 @@ +package model + +import ( + "strings" + "time" + + "github.com/uptrace/bun" +) + +type Quote struct { + bun.BaseModel `bun:"table:quotes,alias:q"` + + ID int64 `bun:",pk,autoincrement"` + Quote string `bun:",notnull"` + Approved bool + Archive bool + CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` + DeletedAt time.Time `bun:",soft_delete,nullzero"` +} + +func (q *Quote) Text() string { + return strings.ReplaceAll(q.Quote, "\n", "
") +} -- cgit v1.2.3