aboutsummaryrefslogtreecommitdiff
path: root/pkg/model/quote.go
blob: 1e397b824a750e985923afe6c09afa46ff49341c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
	Rating    int
	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", "<br />")
}