db

package
v0.0.0-...-ec10a6c Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: GPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("record not found")
)

Functions

This section is empty.

Types

type DBConfig

type DBConfig struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
	SSL      bool
}

type DBConn

type DBConn struct {
	*xorm.Engine
}
var (
	DB *DBConn
)

func NewDB

func NewDB(config *DBConfig) (*DBConn, error)

func (*DBConn) Close

func (db *DBConn) Close() error

func (*DBConn) Migrate

func (db *DBConn) Migrate() (int, error)

type Repository

type Repository[Entity any, ID any] struct {
}

func (*Repository[Entity, ID]) Create

func (r *Repository[Entity, ID]) Create(entity *Entity) error

func (*Repository[Entity, ID]) Delete

func (r *Repository[Entity, ID]) Delete(filter *Entity) (affected int, err error)

func (*Repository[Entity, ID]) DeleteByID

func (r *Repository[Entity, ID]) DeleteByID(id ID) error

func (*Repository[Entity, ID]) FindOne

func (r *Repository[Entity, ID]) FindOne(filter *Entity) (*Entity, error)

func (*Repository[Entity, ID]) FindOneByID

func (r *Repository[Entity, ID]) FindOneByID(id ID) (*Entity, error)

func (*Repository[Entity, ID]) Update

func (r *Repository[Entity, ID]) Update(filter *Entity, entity *Entity) (affected int, err error)

func (*Repository[Entity, ID]) UpdateByID

func (r *Repository[Entity, ID]) UpdateByID(id ID, entity *Entity) error

func (*Repository[Entity, ID]) Upsert

func (r *Repository[Entity, ID]) Upsert(id ID, entity *Entity) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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