sqlite

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EqualPredicate              = Predicate("=")
	NotEqualPredicate           = Predicate("<>")
	GreaterThanPredicate        = Predicate(">")
	GreaterThanOrEqualPredicate = Predicate(">=")
	SmallerThanPredicate        = Predicate("<")
	SmallerThanOrEqualPredicate = Predicate("<=")
	LikePredicate               = Predicate("LIKE")
)
View Source
const (
	CreateErrStr  = "create error"
	UpdatesErrStr = "updates error"
	DeleteErrStr  = "delete error"
)

err 常量

View Source
const (
	DescStr  = "DESC"
	AscStr   = "ASC"
	InStr    = "IN"
	NotInStr = "NOT IN"
)

查询常量

Variables

This section is empty.

Functions

func Dsn

func Dsn(filename string) string

Types

type DB

type DB struct {
	Db *gorm.DB
}

func (*DB) Close

func (d *DB) Close() error

func (*DB) GetDb

func (d *DB) GetDb() *gorm.DB

type Info

type Info struct {
	FileName        string        `toml:"FileName" json:"FileName"`               // sqlite文件名
	MaxOpenConn     int           `toml:"MaxOpenConn" json:"MaxOpenConn"`         // 最大连接数
	MaxIDleConn     int           `toml:"MaxIDleConn" json:"MaxIDleConn"`         // 最大空闲连接数
	ConnMaxLifeTime time.Duration `toml:"ConnMaxLifeTime" json:"ConnMaxLifeTime"` // 最大连接超时时间, 单位分钟
}

type Predicate

type Predicate string

Predicate is a string that acts as a condition in the where clause

type QueryBuilder

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

func NewQueryBuilder

func NewQueryBuilder(model interface{}, mustBeField ...string) *QueryBuilder

func (*QueryBuilder) BuildQuery

func (qb *QueryBuilder) BuildQuery(db *gorm.DB) *gorm.DB

func (*QueryBuilder) Count

func (qb *QueryBuilder) Count(db *gorm.DB) (int64, error)

func (*QueryBuilder) Create

func (qb *QueryBuilder) Create(db *gorm.DB, model interface{}) (rowsAffected int64, err error)

func (*QueryBuilder) Delete

func (qb *QueryBuilder) Delete(db *gorm.DB) (rowsAffected int64, err error)

func (*QueryBuilder) Exist

func (qb *QueryBuilder) Exist(db *gorm.DB) (bool, error)

func (*QueryBuilder) First

func (qb *QueryBuilder) First(db *gorm.DB, ret interface{}) error

func (*QueryBuilder) Get

func (qb *QueryBuilder) Get(db *gorm.DB, ret interface{}) error

func (*QueryBuilder) GroupBy

func (qb *QueryBuilder) GroupBy(field string) *QueryBuilder

func (*QueryBuilder) Limit

func (qb *QueryBuilder) Limit(limit int) *QueryBuilder

func (*QueryBuilder) List

func (qb *QueryBuilder) List(db *gorm.DB, ret interface{}) error

func (*QueryBuilder) Offset

func (qb *QueryBuilder) Offset(offset int) *QueryBuilder

func (*QueryBuilder) OrderBy

func (qb *QueryBuilder) OrderBy(field string, sortType pagex.SortType) *QueryBuilder

func (*QueryBuilder) Page

func (qb *QueryBuilder) Page(db *gorm.DB, val interface{}, param *pagex.Params) (*pagex.Result, error)

func (*QueryBuilder) SetModel

func (qb *QueryBuilder) SetModel(model interface{})

func (*QueryBuilder) Transaction

func (qb *QueryBuilder) Transaction(db *gorm.DB, fc func(tx *gorm.DB) error, opts ...*sql.TxOptions) (err error)

func (*QueryBuilder) Updates

func (qb *QueryBuilder) Updates(db *gorm.DB, m map[string]interface{}) (rowsAffected int64, err error)

func (*QueryBuilder) Where

func (qb *QueryBuilder) Where(p Predicate, field string, value interface{}) *QueryBuilder

func (*QueryBuilder) WhereIn

func (qb *QueryBuilder) WhereIn(field string, value interface{}) *QueryBuilder

func (*QueryBuilder) WhereNotIn

func (qb *QueryBuilder) WhereNotIn(field string, value interface{}) *QueryBuilder

type Repo

type Repo interface {
	GetDb() *gorm.DB
	Close() error
}

func Default

func Default() Repo

func New

func New(cfg Info) (Repo, error)

type User

type User struct {
	Name string
	Age  int
}

Jump to

Keyboard shortcuts

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