db

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package db contains show related CRUD functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Show

type Show struct {
	ID           string    `db:"show_id"`
	Enable       bool      `db:"enable"`
	Platform     string    `db:"platform"`
	RoomID       string    `db:"room_id"`
	StreamerName string    `db:"streamer_name"`
	OutTmpl      string    `db:"out_tmpl"`
	Parser       string    `db:"parser"`
	SaveDir      string    `db:"save_dir"`
	PostCmds     string    `db:"post_cmds"`
	SplitRule    string    `db:"split_rule"`
	DateCreated  time.Time `db:"date_created"`
	DateUpdated  time.Time `db:"date_updated"`
}

Show represent the structure we need for moving data between the app and the database.

type Store

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

Store manages the set of APIs for show access.

func NewStore

func NewStore(log *zap.SugaredLogger, db *sqlx.DB) Store

NewStore constructs a data for api access.

func (Store) Create

func (s Store) Create(ctx context.Context, show Show) error

Create inserts a new show into the database.

func (Store) Delete

func (s Store) Delete(ctx context.Context, showIDList []string) error

Delete removes one or many shows from the database.

func (Store) Query

func (s Store) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]Show, error)

Query retrieves a list of existing shows from the database.

func (Store) QueryAllEnabled

func (s Store) QueryAllEnabled(ctx context.Context) ([]Show, error)

QueryAllEnabled retrieves all shows which `enable` equals true from the database.

func (Store) QueryByID

func (s Store) QueryByID(ctx context.Context, showID string) (Show, error)

QueryByID gets the specified show from the database.

func (Store) TotalNum

func (s Store) TotalNum(ctx context.Context) (int64, error)

TotalNum gets the total number of shows from the database.

func (Store) Tran

func (s Store) Tran(tx sqlx.ExtContext) Store

Tran return new Store with transaction in it.

func (Store) Update

func (s Store) Update(ctx context.Context, show Show) error

Update replaces a show document in the database.

func (Store) WithinTran

func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error

WithinTran runs passed function and do commit/rollback at the end.

Jump to

Keyboard shortcuts

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