model

package
v1.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CollectionName = "blogs"

Variables

This section is empty.

Functions

This section is empty.

Types

type Blog

type Blog struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Title       string             `bson:"title" validate:"required,max=500"`
	Description string             `bson:"description" validate:"required,max=2000"`
	Text        *string            `bson:"text,omitempty"`
	DraftText   string             `bson:"draftText" validate:"required"`
	Tags        []string           `bson:"tags" validate:"required"`
	Author      primitive.ObjectID `bson:"author" validate:"required"`
	ImgURL      *string            `bson:"imgUrl,omitempty"`
	Slug        string             `bson:"slug" validate:"required,min=3,max=200"`
	Score       float64            `bson:"score" validate:"min=0,max=1"`
	Submitted   bool               `bson:"submitted"`
	Drafted     bool               `bson:"drafted"`
	Published   bool               `bson:"published"`
	Status      bool               `bson:"status"`
	PublishedAt *time.Time         `bson:"publishedAt,omitempty"`
	CreatedBy   primitive.ObjectID `bson:"createdBy" validate:"required"`
	UpdatedBy   primitive.ObjectID `bson:"updatedBy" validate:"required"`
	CreatedAt   time.Time          `bson:"createdAt" validate:"required"`
	UpdatedAt   time.Time          `bson:"updatedAt" validate:"required"`
}

func NewBlog

func NewBlog(slug, title, description, draftText string, tags []string, author *model.User) (*Blog, error)

func (*Blog) EnsureIndexes

func (*Blog) EnsureIndexes(db mongo.Database)

func (*Blog) GetValue

func (blog *Blog) GetValue() *Blog

func (*Blog) Validate

func (blog *Blog) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL