orm

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoRecord = fmt.Errorf("no record found")

Functions

func Decode

func Decode(src string) string

func Encode

func Encode(src string) string

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 SetCipher

func SetCipher(c Cipher)

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)

Types

type Cipher

type Cipher interface {
	Encode(string) string
	Decode(string) string
}

type DB

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

func OpenTrace

func OpenTrace(ctx context.Context, db DB) DB

type DBQuerySession

type DBQuerySession struct {
	*DBStore
	Ctx context.Context
}

type DBStore

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

func NewDBStore

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

func NewDBStoreCharset

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

func (*DBStore) BeginTx

func (store *DBStore) BeginTx(ctx context.Context) (TX, 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) Query

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

func (*DBStore) SetError

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) BeginTx

func (tx *DBTx) BeginTx(ctx context.Context) (TX, error)

func (*DBTx) Close

func (tx *DBTx) Close() error

func (*DBTx) Exec

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

func (*DBTx) ExecContext added in v0.9.3

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

func (*DBTx) GetContext

func (tx *DBTx) GetContext() context.Context

func (*DBTx) Prepare added in v0.9.3

func (tx *DBTx) Prepare(query string) (*sql.Stmt, error)

func (*DBTx) Query

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

func (*DBTx) QueryContext added in v0.9.3

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

func (*DBTx) QueryRow added in v0.9.3

func (tx *DBTx) QueryRow(query string, args ...interface{}) *sql.Row

func (*DBTx) QueryRowContext added in v0.9.3

func (tx *DBTx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

func (*DBTx) SetContext

func (tx *DBTx) SetContext(ctx context.Context)

func (*DBTx) SetError

func (tx *DBTx) SetError(err error)

type FieldIN

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

func NewFieldIN

func NewFieldIN(field string) *FieldIN

func (*FieldIN) Add

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

func (*FieldIN) SQLFormat

func (in *FieldIN) SQLFormat() string

func (*FieldIN) SQLFormatNotIn

func (in *FieldIN) SQLFormatNotIn() string

func (*FieldIN) SQLParams

func (in *FieldIN) 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 Set

type Set interface {
	// Returns a new Set that contains exactly the same elements as this set.
	Copy() Set

	// Returns the cardinality of this set.
	Len() int

	// Returns true if and only if this set contains v (according to Go equality rules).
	Contains(v string) bool
	// Inserts v into this set.
	Add(v string)
	// Removes v from this set, if it is present.  Returns true if and only if v was present.
	Remove(v string) bool
	// Return All Keys
	ToArray() []string

	// Executes f(v) for every element v in this set.  If f mutates this set, behavior is undefined.
	Do(f func(string))
	// Executes f(v) once for every element v in the set, aborting if f ever returns false. If f
	// mutates this set, behavior is undefined.
	DoWhile(f func(string) bool)
	// Returns a channel from which each element in the set can be read exactly once.  If this set
	// is mutated before the channel is emptied, the exact data read from the channel is undefined.
	Iter() <-chan string

	// Adds every element in s into this set.
	Union(s Set)
	// Removes every element not in s from this set.
	Intersect(s Set)
	// Removes every element in s from this set.
	Subtract(s Set)
	// Removes all elements from the set.
	Init()
	// Returns true if and only if all elements in this set are elements in s.
	IsSubset(s Set) bool
	// Returns true if and only if all elements in s are elements in this set.
	IsSuperset(s Set) bool
	// Returns true if and only if this set and s contain exactly the same elements.
	IsEqual(s Set) bool
	// Removes all elements v from this set that satisfy f(v) == true.
	RemoveIf(f func(string) bool)
}

An unordered collection of unique elements which supports lookups, insertions, deletions, iteration, and common binary set operations. It is not guaranteed to be thread-safe.

func Intersect

func Intersect(s1 Set, s2 Set) Set

Returns a new set which is the intersect of s1 and s2. s1 and s2 are unmodified.

func NewStringSet

func NewStringSet(items ...string) Set

Returns a new Set pre-populated with the given items

func Subtract

func Subtract(s1 Set, s2 Set) Set

Returns a new set which is the difference between s1 and s2. s1 and s2 are unmodified.

func Union

func Union(s1 Set, s2 Set) Set

Returns a new set which is the union of s1 and s2. s1 and s2 are unmodified.

type TX

type TX interface {
	Close() error
	GetContext() context.Context
	Prepare(query string) (*sql.Stmt, error)
	QueryRow(query string, args ...interface{}) *sql.Row

	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
	DB
}

type TracedDB

type TracedDB struct {
	DB
	// contains filtered or unexported fields
}

func (*TracedDB) Exec

func (db *TracedDB) Exec(sql string, args ...interface{}) (sql.Result, error)

func (*TracedDB) Query

func (db *TracedDB) Query(sql string, args ...interface{}) (*sql.Rows, error)

func (*TracedDB) SetError

func (db *TracedDB) SetError(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