dao

package
v0.0.0-...-3beaeaf Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArticleDuplicated = errors.New("article already exists")
	ErrArticleNotFound   = errors.New("article not found")
)

Functions

func InitTables

func InitTables(db *gorm.DB) error

Types

type Article

type Article struct {
	ID uint `gorm:"primaryKey"`

	UserID  uint   `gorm:"uniqueIndex:idx_user_id_title,not null"`
	Title   string `gorm:"uniqueIndex:idx_user_id_title,not null"`
	Content string `gorm:"not null"`

	CreatedAt time.Time `gorm:"not null"`
	UpdatedAt time.Time `gorm:"not null"`
}

type ArticleDAO

type ArticleDAO struct {
	// contains filtered or unexported fields
}

func NewArticleDAO

func NewArticleDAO(db *gorm.DB) *ArticleDAO

func (*ArticleDAO) FindAll

func (d *ArticleDAO) FindAll(ctx context.Context, page, perPage uint) ([]Article, error)

func (*ArticleDAO) FindByID

func (d *ArticleDAO) FindByID(ctx context.Context, id uint) (Article, error)

func (*ArticleDAO) Insert

func (d *ArticleDAO) Insert(ctx context.Context, article Article) (Article, error)

func (*ArticleDAO) Search

func (d *ArticleDAO) Search(ctx context.Context, title, content string) ([]Article, error)

Jump to

Keyboard shortcuts

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