orm

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(src string) string

func Encode

func Encode(src string) string

func IsErrNotFound added in v1.5.1

func IsErrNotFound(err error) bool

IsErrNotFound represents the mysql db rows not found error should be compatible with FetchByPrimaryKey and FetchByPK

func MsSQLOffsetLimit

func MsSQLOffsetLimit(offset, limit int) string

func MsSQLTimeFormat

func MsSQLTimeFormat(t interface{}) string

func MsSQLTimeParse

func MsSQLTimeParse(s string) time.Time

func NewStringSlice

func NewStringSlice(len int, val string) []string

func PrimaryComparator

func PrimaryComparator(a, b interface{}) int

func SQLOffsetLimit

func SQLOffsetLimit(offset, limit int) string

func SQLOrderBy

func SQLOrderBy(field string, revert bool) string

func SQLWhere

func SQLWhere(conditions []string) string

func SliceJoin

func SliceJoin(objs []interface{}, sep string) string

func StringScan

func StringScan(str string, v interface{}) error

func TimeFormat

func TimeFormat(t time.Time) string

func TimeParse

func TimeParse(s string) time.Time

func TimeParseLocalTime

func TimeParseLocalTime(s string) time.Time

func TimeToLocalTime

func TimeToLocalTime(c time.Time) string

func ToFloat64

func ToFloat64(value interface{}) (float64, error)

func Transact added in v1.5.0

func Transact(db *DBStore, t Transactor) error

func TransactFunc added in v1.5.0

func TransactFunc(db *DBStore, txFunc func(*DBTx) error) (err error)

Types

type DB

type DB interface {
	Query(sql string, args ...interface{}) (*sql.Rows, error)
	Exec(sql string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, sql string, args ...interface{}) (*sql.Rows, error)
	ExecContext(ctx context.Context, sql string, args ...interface{}) (sql.Result, error)
	SetError(err error)
}

type DBStore

type DBStore struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewDBDSNStore added in v1.5.0

func NewDBDSNStore(driver, dsn string) (*DBStore, error)

func NewDBStore

func NewDBStore(driver, host string, port int, database, username, password string) (*DBStore, error)

func NewDBStoreCharset added in v1.0.3

func NewDBStoreCharset(driver, host string, port int, databaseName, username, password, charset string) (*DBStore, error)

func NewDBStoreWithRawDB added in v1.5.0

func NewDBStoreWithRawDB(db *sql.DB) *DBStore

func (*DBStore) AddWrappers added in v1.5.0

func (store *DBStore) AddWrappers(wp ...database.Wrapper)

func (*DBStore) BeginTx

func (store *DBStore) BeginTx() (*DBTx, error)

func (*DBStore) Close

func (store *DBStore) Close() error

func (*DBStore) Debug

func (store *DBStore) Debug(b bool)

func (*DBStore) Exec

func (store *DBStore) Exec(sql string, args ...interface{}) (sql.Result, error)

func (*DBStore) ExecContext added in v1.5.0

func (store *DBStore) ExecContext(ctx context.Context, query string,
	args ...interface{}) (sql.Result, error)

func (*DBStore) Query

func (store *DBStore) Query(sql string, args ...interface{}) (*sql.Rows, error)

func (*DBStore) QueryContext added in v1.5.0

func (store *DBStore) QueryContext(ctx context.Context, query string,
	args ...interface{}) (*sql.Rows, error)

func (*DBStore) SetError added in v1.0.2

func (store *DBStore) SetError(err error)

func (*DBStore) SlowLog

func (store *DBStore) SlowLog(duration time.Duration)

type DBTx

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

func (*DBTx) Close

func (tx *DBTx) Close() error

func (*DBTx) Exec

func (tx *DBTx) Exec(sql string, args ...interface{}) (sql.Result, error)

func (*DBTx) ExecContext added in v1.5.0

func (tx *DBTx) ExecContext(ctx context.Context, query string,
	args ...interface{}) (sql.Result, error)

func (*DBTx) Query

func (tx *DBTx) Query(sql string, args ...interface{}) (*sql.Rows, error)

func (*DBTx) QueryContext added in v1.5.0

func (tx *DBTx) QueryContext(ctx context.Context, query string,
	args ...interface{}) (*sql.Rows, error)

func (*DBTx) SetError added in v1.0.2

func (tx *DBTx) SetError(err error)

type FieldIN added in v1.0.4

type FieldIN struct {
	Field  string
	Params []interface{}
	// contains filtered or unexported fields
}

func NewFieldIN added in v1.0.4

func NewFieldIN(field string) *FieldIN

func (*FieldIN) Add added in v1.0.4

func (in *FieldIN) Add(v interface{}) *FieldIN

func (*FieldIN) SQLFormat added in v1.0.4

func (in *FieldIN) SQLFormat() string

func (*FieldIN) SQLParams added in v1.0.4

func (in *FieldIN) SQLParams() []interface{}

type FieldMultiIN added in v1.5.2

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

func NewMultiFieldIN added in v1.5.2

func NewMultiFieldIN(fields []string) *FieldMultiIN

func (*FieldMultiIN) Add added in v1.5.2

func (in *FieldMultiIN) Add(v []interface{}) error

func (*FieldMultiIN) SQLFormat added in v1.5.2

func (in *FieldMultiIN) SQLFormat() string

func (*FieldMultiIN) SQLParams added in v1.5.2

func (in *FieldMultiIN) SQLParams() []interface{}

type RedisStore

type RedisStore struct {
	redis.Cmdable
}

func NewRedisClient

func NewRedisClient(host string, port int, password string, db int) (*RedisStore, error)

func NewRedisClusterClient

func NewRedisClusterClient(opt *redis.ClusterOptions) (*RedisStore, error)

func NewRedisFailoverClient

func NewRedisFailoverClient(failoverOpt *redis.FailoverOptions) (*RedisStore, error)

func NewRedisRingClient

func NewRedisRingClient(opt *redis.RingOptions) (*RedisStore, error)

type Transactor added in v1.5.0

type Transactor interface {
	Transact(tx *DBTx) error
}

type VSet

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

func NewVSet

func NewVSet() *VSet

func (*VSet) Add

func (set *VSet) Add(items ...interface{})

func (*VSet) Clear

func (set *VSet) Clear()

func (*VSet) Remove

func (set *VSet) Remove(items ...string)

func (*VSet) SortAdd

func (set *VSet) SortAdd(times int, items ...interface{})

func (*VSet) Unions

func (set *VSet) Unions(offset int, limit int) []interface{}

func (*VSet) Values

func (set *VSet) Values(times int, offset int, limit int) []interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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