dao

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidTransactionError = errors.New("invalid transaction, it is already committed or roll backed")

Functions

func GetOpus

func GetOpus(tx *TX, options ...Option) (*model.Opus, bool, error)

func GetOpusByID

func GetOpusByID(tx *TX, id string) (*model.Opus, bool, error)

func GetOpusVersion

func GetOpusVersion(tx *TX, option ...Option) (*model.OpusVersion, bool, error)

func GetPresentationByVersionID

func GetPresentationByVersionID(versionID string) (*model.OpusPresentation, bool)

func GetReadme

func GetReadme(tx *TX, option ...Option) (*model.OpusReadme, bool, error)

func Init

func Init(db *gorm.DB)

func ListOpuses

func ListOpuses(tx *TX, options ...Option) (int64, []*model.Opus, error)

func ListPresentations

func ListPresentations(tx *TX, options ...Option) (int64, []*model.OpusPresentation, error)

func ListReadmes

func ListReadmes(tx *TX, options ...Option) (int64, []*model.OpusReadme, error)

func ListVersions

func ListVersions(tx *TX, options ...Option) (int64, []*model.OpusVersion, error)

Types

type Option

type Option interface {
	With(db *gorm.DB) *gorm.DB
}

func ByIDOption

func ByIDOption(id interface{}) Option

func InOption

func InOption(col string, values map[interface{}]struct{}) Option

func MapOption

func MapOption(m map[string]interface{}) Option

func OrderByOption

func OrderByOption(col string, order string) Option

func PageOption

func PageOption(pageSize, pageNo int) Option

func WhereOption

func WhereOption(format string, args ...interface{}) Option

type TX

type TX struct {
	Error error
	// contains filtered or unexported fields
}

func Begin

func Begin() *TX

func Q

func Q() *TX

func (*TX) CommitOrRollback

func (tx *TX) CommitOrRollback()

func (*TX) Create

func (tx *TX) Create(i interface{}) error

func (*TX) CreateInBatches

func (tx *TX) CreateInBatches(i interface{}, size int) error

func (*TX) DB

func (tx *TX) DB() *gorm.DB

func (*TX) Delete

func (tx *TX) Delete(i interface{}, options ...Option) error

func (*TX) Get

func (tx *TX) Get(i interface{}, options ...Option) (bool, error)

func (*TX) List

func (tx *TX) List(i interface{}, options ...Option) (int64, error)

func (*TX) Updates

func (tx *TX) Updates(i, v interface{}, options ...Option) error

Jump to

Keyboard shortcuts

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