core: github.com/go-xorm/core Index | Files

package core

import "github.com/go-xorm/core"

Index

Package Files

cache.go column.go converstion.go db.go dialect.go driver.go error.go filter.go ilogger.go index.go mapper.go pk.go rows.go scan.go table.go type.go

Constants

const (
    // default cache expired time
    CacheExpired = 60 * time.Minute
    // not use now
    CacheMaxMemory = 256
    // evey ten minutes to clear all expired nodes
    CacheGcInterval = 10 * time.Minute
    // each time when gc to removed max nodes
    CacheGcMaxRemoved = 20
)
const (
    TWOSIDES = iota + 1
    ONLYTODB
    ONLYFROMDB
)
const (
    IndexType = iota + 1
    UniqueType
)
const (
    POSTGRES = "postgres"
    SQLITE   = "sqlite3"
    MYSQL    = "mysql"
    MSSQL    = "mssql"
    ORACLE   = "oracle"
)
const (
    UNKNOW_TYPE = iota
    TEXT_TYPE
    BLOB_TYPE
    TIME_TYPE
    NUMERIC_TYPE
)

Variables

var (
    ErrCacheMiss = errors.New("xorm/cache: key not found.")
    ErrNotStored = errors.New("xorm/cache: not stored.")
)
var (
    ErrNoMapPointer    = errors.New("mp should be a map's pointer")
    ErrNoStructPointer = errors.New("mp should be a struct's pointer")
)
var (
    Bit       = "BIT"
    TinyInt   = "TINYINT"
    SmallInt  = "SMALLINT"
    MediumInt = "MEDIUMINT"
    Int       = "INT"
    Integer   = "INTEGER"
    BigInt    = "BIGINT"

    Enum = "ENUM"
    Set  = "SET"

    Char       = "CHAR"
    Varchar    = "VARCHAR"
    NVarchar   = "NVARCHAR"
    TinyText   = "TINYTEXT"
    Text       = "TEXT"
    Clob       = "CLOB"
    MediumText = "MEDIUMTEXT"
    LongText   = "LONGTEXT"
    Uuid       = "UUID"

    Date       = "DATE"
    DateTime   = "DATETIME"
    Time       = "TIME"
    TimeStamp  = "TIMESTAMP"
    TimeStampz = "TIMESTAMPZ"

    Decimal = "DECIMAL"
    Numeric = "NUMERIC"

    Real   = "REAL"
    Float  = "FLOAT"
    Double = "DOUBLE"

    Binary     = "BINARY"
    VarBinary  = "VARBINARY"
    TinyBlob   = "TINYBLOB"
    Blob       = "BLOB"
    MediumBlob = "MEDIUMBLOB"
    LongBlob   = "LONGBLOB"
    Bytea      = "BYTEA"

    Bool    = "BOOL"
    Boolean = "BOOLEAN"

    Serial    = "SERIAL"
    BigSerial = "BIGSERIAL"

    Json  = "JSON"
    Jsonb = "JSONB"

    SqlTypes = map[string]int{
        Bit:       NUMERIC_TYPE,
        TinyInt:   NUMERIC_TYPE,
        SmallInt:  NUMERIC_TYPE,
        MediumInt: NUMERIC_TYPE,
        Int:       NUMERIC_TYPE,
        Integer:   NUMERIC_TYPE,
        BigInt:    NUMERIC_TYPE,

        Enum:  TEXT_TYPE,
        Set:   TEXT_TYPE,
        Json:  TEXT_TYPE,
        Jsonb: TEXT_TYPE,

        Char:       TEXT_TYPE,
        Varchar:    TEXT_TYPE,
        NVarchar:   TEXT_TYPE,
        TinyText:   TEXT_TYPE,
        Text:       TEXT_TYPE,
        MediumText: TEXT_TYPE,
        LongText:   TEXT_TYPE,
        Uuid:       TEXT_TYPE,
        Clob:       TEXT_TYPE,

        Date:       TIME_TYPE,
        DateTime:   TIME_TYPE,
        Time:       TIME_TYPE,
        TimeStamp:  TIME_TYPE,
        TimeStampz: TIME_TYPE,

        Decimal: NUMERIC_TYPE,
        Numeric: NUMERIC_TYPE,
        Real:    NUMERIC_TYPE,
        Float:   NUMERIC_TYPE,
        Double:  NUMERIC_TYPE,

        Binary:    BLOB_TYPE,
        VarBinary: BLOB_TYPE,

        TinyBlob:   BLOB_TYPE,
        Blob:       BLOB_TYPE,
        MediumBlob: BLOB_TYPE,
        LongBlob:   BLOB_TYPE,
        Bytea:      BLOB_TYPE,

        Bool: NUMERIC_TYPE,

        Serial:    NUMERIC_TYPE,
        BigSerial: NUMERIC_TYPE,
    }
)
var (
    IntType   = reflect.TypeOf(c_INT_DEFAULT)
    Int8Type  = reflect.TypeOf(c_INT8_DEFAULT)
    Int16Type = reflect.TypeOf(c_INT16_DEFAULT)
    Int32Type = reflect.TypeOf(c_INT32_DEFAULT)
    Int64Type = reflect.TypeOf(c_INT64_DEFAULT)

    UintType   = reflect.TypeOf(c_UINT_DEFAULT)
    Uint8Type  = reflect.TypeOf(c_UINT8_DEFAULT)
    Uint16Type = reflect.TypeOf(c_UINT16_DEFAULT)
    Uint32Type = reflect.TypeOf(c_UINT32_DEFAULT)
    Uint64Type = reflect.TypeOf(c_UINT64_DEFAULT)

    Float32Type = reflect.TypeOf(c_FLOAT32_DEFAULT)
    Float64Type = reflect.TypeOf(c_FLOAT64_DEFAULT)

    Complex64Type  = reflect.TypeOf(c_COMPLEX64_DEFAULT)
    Complex128Type = reflect.TypeOf(c_COMPLEX128_DEFAULT)

    StringType = reflect.TypeOf(c_EMPTY_STRING)
    BoolType   = reflect.TypeOf(c_BOOL_DEFAULT)
    ByteType   = reflect.TypeOf(c_BYTE_DEFAULT)
    BytesType  = reflect.SliceOf(ByteType)

    TimeType = reflect.TypeOf(c_TIME_DEFAULT)
)
var (
    PtrIntType   = reflect.PtrTo(IntType)
    PtrInt8Type  = reflect.PtrTo(Int8Type)
    PtrInt16Type = reflect.PtrTo(Int16Type)
    PtrInt32Type = reflect.PtrTo(Int32Type)
    PtrInt64Type = reflect.PtrTo(Int64Type)

    PtrUintType   = reflect.PtrTo(UintType)
    PtrUint8Type  = reflect.PtrTo(Uint8Type)
    PtrUint16Type = reflect.PtrTo(Uint16Type)
    PtrUint32Type = reflect.PtrTo(Uint32Type)
    PtrUint64Type = reflect.PtrTo(Uint64Type)

    PtrFloat32Type = reflect.PtrTo(Float32Type)
    PtrFloat64Type = reflect.PtrTo(Float64Type)

    PtrComplex64Type  = reflect.PtrTo(Complex64Type)
    PtrComplex128Type = reflect.PtrTo(Complex128Type)

    PtrStringType = reflect.PtrTo(StringType)
    PtrBoolType   = reflect.PtrTo(BoolType)
    PtrByteType   = reflect.PtrTo(ByteType)

    PtrTimeType = reflect.PtrTo(TimeType)
)
var LintGonicMapper = GonicMapper{
    "API":   true,
    "ASCII": true,
    "CPU":   true,
    "CSS":   true,
    "DNS":   true,
    "EOF":   true,
    "GUID":  true,
    "HTML":  true,
    "HTTP":  true,
    "HTTPS": true,
    "ID":    true,
    "IP":    true,
    "JSON":  true,
    "LHS":   true,
    "QPS":   true,
    "RAM":   true,
    "RHS":   true,
    "RPC":   true,
    "SLA":   true,
    "SMTP":  true,
    "SSH":   true,
    "TLS":   true,
    "TTL":   true,
    "UI":    true,
    "UID":   true,
    "UUID":  true,
    "URI":   true,
    "URL":   true,
    "UTF8":  true,
    "VM":    true,
    "XML":   true,
    "XSRF":  true,
    "XSS":   true,
}

A GonicMapper that contains a list of common initialisms taken from golang/lint

func GenSqlKey Uses

func GenSqlKey(sql string, args interface{}) string

func GetCacheSql Uses

func GetCacheSql(m Cacher, tableName, sql string, args interface{}) ([]PK, error)

func MapToSlice Uses

func MapToSlice(query string, mp interface{}) (string, []interface{}, error)

func PutCacheSql Uses

func PutCacheSql(m Cacher, ids []PK, tableName, sql string, args interface{}) error

func ReflectNew Uses

func ReflectNew(typ reflect.Type) reflect.Value

func RegisterDialect Uses

func RegisterDialect(dbName DbType, dialectFunc func() Dialect)

RegisterDialect register database dialect

func RegisterDriver Uses

func RegisterDriver(driverName string, driver Driver)

func RegisteredDriverSize Uses

func RegisteredDriverSize() int

func SQLType2Type Uses

func SQLType2Type(st SQLType) reflect.Type

default sql type change to go types

func StructToSlice Uses

func StructToSlice(query string, st interface{}) (string, []interface{}, error)

type Base Uses

type Base struct {
    *Uri
    // contains filtered or unexported fields
}

func (*Base) AndStr Uses

func (b *Base) AndStr() string

func (*Base) CreateIndexSql Uses

func (db *Base) CreateIndexSql(tableName string, index *Index) string

func (*Base) CreateTableSql Uses

func (b *Base) CreateTableSql(table *Table, tableName, storeEngine, charset string) string

func (*Base) DB Uses

func (b *Base) DB() *DB

func (*Base) DBType Uses

func (b *Base) DBType() DbType

func (*Base) DataSourceName Uses

func (b *Base) DataSourceName() string

func (*Base) DriverName Uses

func (b *Base) DriverName() string

func (*Base) DropIndexSql Uses

func (db *Base) DropIndexSql(tableName string, index *Index) string

func (*Base) DropTableSql Uses

func (db *Base) DropTableSql(tableName string) string

func (*Base) EqStr Uses

func (b *Base) EqStr() string

func (*Base) ForUpdateSql Uses

func (b *Base) ForUpdateSql(query string) string

func (*Base) FormatBytes Uses

func (b *Base) FormatBytes(bs []byte) string

func (*Base) HasRecords Uses

func (db *Base) HasRecords(query string, args ...interface{}) (bool, error)

func (*Base) Init Uses

func (b *Base) Init(db *DB, dialect Dialect, uri *Uri, drivername, dataSourceName string) error

func (*Base) IsColumnExist Uses

func (db *Base) IsColumnExist(tableName, colName string) (bool, error)

func (*Base) LogSQL Uses

func (b *Base) LogSQL(sql string, args []interface{})

func (*Base) ModifyColumnSql Uses

func (db *Base) ModifyColumnSql(tableName string, col *Column) string

func (*Base) OrStr Uses

func (b *Base) OrStr() string

func (*Base) RollBackStr Uses

func (db *Base) RollBackStr() string

func (*Base) SetLogger Uses

func (b *Base) SetLogger(logger ILogger)

func (*Base) ShowCreateNull Uses

func (b *Base) ShowCreateNull() bool

func (*Base) SupportDropIfExists Uses

func (db *Base) SupportDropIfExists() bool

func (*Base) URI Uses

func (b *Base) URI() *Uri

type CacheMapper Uses

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

func NewCacheMapper Uses

func NewCacheMapper(mapper IMapper) *CacheMapper

func (*CacheMapper) Obj2Table Uses

func (m *CacheMapper) Obj2Table(o string) string

func (*CacheMapper) Table2Obj Uses

func (m *CacheMapper) Table2Obj(t string) string

type CacheStore Uses

type CacheStore interface {
    // key is primary key or composite primary key
    // value is struct's pointer
    // key format : <tablename>-p-<pk1>-<pk2>...
    Put(key string, value interface{}) error
    Get(key string) (interface{}, error)
    Del(key string) error
}

CacheStore is a interface to store cache

type Cacher Uses

type Cacher interface {
    GetIds(tableName, sql string) interface{}
    GetBean(tableName string, id string) interface{}
    PutIds(tableName, sql string, ids interface{})
    PutBean(tableName string, id string, obj interface{})
    DelIds(tableName, sql string)
    DelBean(tableName string, id string)
    ClearIds(tableName string)
    ClearBeans(tableName string)
}

Cacher is an interface to provide cache id format : u-<pk1>-<pk2>...

type Column Uses

type Column struct {
    Name            string
    TableName       string
    FieldName       string
    SQLType         SQLType
    IsJSON          bool
    Length          int
    Length2         int
    Nullable        bool
    Default         string
    Indexes         map[string]int
    IsPrimaryKey    bool
    IsAutoIncrement bool
    MapType         int
    IsCreated       bool
    IsUpdated       bool
    IsDeleted       bool
    IsCascade       bool
    IsVersion       bool
    DefaultIsEmpty  bool
    EnumOptions     map[string]int
    SetOptions      map[string]int
    DisableTimeZone bool
    TimeZone        *time.Location // column specified time zone
    Comment         string
}

Column defines database column

func NewColumn Uses

func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column

func (*Column) String Uses

func (col *Column) String(d Dialect) string

generate column description string according dialect

func (*Column) StringNoPk Uses

func (col *Column) StringNoPk(d Dialect) string

func (*Column) ValueOf Uses

func (col *Column) ValueOf(bean interface{}) (*reflect.Value, error)

return col's filed of struct's value

func (*Column) ValueOfV Uses

func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error)

type Conversion Uses

type Conversion interface {
    FromDB([]byte) error
    ToDB() ([]byte, error)
}

Conversion is an interface. A type implements Conversion will according the custom method to fill into database and retrieve from database.

type DB Uses

type DB struct {
    *sql.DB
    Mapper IMapper
}

func FromDB Uses

func FromDB(db *sql.DB) *DB

func Open Uses

func Open(driverName, dataSourceName string) (*DB, error)

func OpenDialect Uses

func OpenDialect(dialect Dialect) (*DB, error)

func (*DB) Begin Uses

func (db *DB) Begin() (*Tx, error)

func (*DB) ExecMap Uses

func (db *DB) ExecMap(query string, mp interface{}) (sql.Result, error)

insert into (name) values (?) insert into (name) values (?name)

func (*DB) ExecStruct Uses

func (db *DB) ExecStruct(query string, st interface{}) (sql.Result, error)

func (*DB) Prepare Uses

func (db *DB) Prepare(query string) (*Stmt, error)

func (*DB) Query Uses

func (db *DB) Query(query string, args ...interface{}) (*Rows, error)

func (*DB) QueryMap Uses

func (db *DB) QueryMap(query string, mp interface{}) (*Rows, error)

func (*DB) QueryRow Uses

func (db *DB) QueryRow(query string, args ...interface{}) *Row

func (*DB) QueryRowMap Uses

func (db *DB) QueryRowMap(query string, mp interface{}) *Row

func (*DB) QueryRowStruct Uses

func (db *DB) QueryRowStruct(query string, st interface{}) *Row

func (*DB) QueryStruct Uses

func (db *DB) QueryStruct(query string, st interface{}) (*Rows, error)

type DbType Uses

type DbType string

type Dialect Uses

type Dialect interface {
    SetLogger(logger ILogger)
    Init(*DB, *Uri, string, string) error
    URI() *Uri
    DB() *DB
    DBType() DbType
    SqlType(*Column) string
    FormatBytes(b []byte) string

    DriverName() string
    DataSourceName() string

    QuoteStr() string
    IsReserved(string) bool
    Quote(string) string
    AndStr() string
    OrStr() string
    EqStr() string
    RollBackStr() string
    AutoIncrStr() string

    SupportInsertMany() bool
    SupportEngine() bool
    SupportCharset() bool
    SupportDropIfExists() bool
    IndexOnTable() bool
    ShowCreateNull() bool

    IndexCheckSql(tableName, idxName string) (string, []interface{})
    TableCheckSql(tableName string) (string, []interface{})

    IsColumnExist(tableName string, colName string) (bool, error)

    CreateTableSql(table *Table, tableName, storeEngine, charset string) string
    DropTableSql(tableName string) string
    CreateIndexSql(tableName string, index *Index) string
    DropIndexSql(tableName string, index *Index) string

    ModifyColumnSql(tableName string, col *Column) string

    ForUpdateSql(query string) string

    GetColumns(tableName string) ([]string, map[string]*Column, error)
    GetTables() ([]*Table, error)
    GetIndexes(tableName string) (map[string]*Index, error)

    Filters() []Filter
}

a dialect is a driver's wrapper

func QueryDialect Uses

func QueryDialect(dbName DbType) Dialect

QueryDialect query if registed database dialect

type Driver Uses

type Driver interface {
    Parse(string, string) (*Uri, error)
}

func QueryDriver Uses

func QueryDriver(driverName string) Driver

type EmptyScanner Uses

type EmptyScanner struct {
}

func (EmptyScanner) Scan Uses

func (EmptyScanner) Scan(src interface{}) error

type Filter Uses

type Filter interface {
    Do(sql string, dialect Dialect, table *Table) string
}

Filter is an interface to filter SQL

type GonicMapper Uses

type GonicMapper map[string]bool

GonicMapper implements IMapper. It will consider initialisms when mapping names. E.g. id -> ID, user -> User and to table names: UserID -> user_id, MyUID -> my_uid

func (GonicMapper) Obj2Table Uses

func (mapper GonicMapper) Obj2Table(name string) string

func (GonicMapper) Table2Obj Uses

func (mapper GonicMapper) Table2Obj(name string) string

type ILogger Uses

type ILogger interface {
    Debug(v ...interface{})
    Debugf(format string, v ...interface{})
    Error(v ...interface{})
    Errorf(format string, v ...interface{})
    Info(v ...interface{})
    Infof(format string, v ...interface{})
    Warn(v ...interface{})
    Warnf(format string, v ...interface{})

    Level() LogLevel
    SetLevel(l LogLevel)

    ShowSQL(show ...bool)
    IsShowSQL() bool
}

logger interface

type IMapper Uses

type IMapper interface {
    Obj2Table(string) string
    Table2Obj(string) string
}

name translation between struct, fields names and table, column names

type IdFilter Uses

type IdFilter struct {
}

IdFilter filter SQL replace (id) to primary key column name

func (*IdFilter) Do Uses

func (i *IdFilter) Do(sql string, dialect Dialect, table *Table) string

type Index Uses

type Index struct {
    IsRegular bool
    Name      string
    Type      int
    Cols      []string
}

database index

func NewIndex Uses

func NewIndex(name string, indexType int) *Index

new an index

func (*Index) AddColumn Uses

func (index *Index) AddColumn(cols ...string)

add columns which will be composite index

func (*Index) Equal Uses

func (index *Index) Equal(dst *Index) bool

func (*Index) XName Uses

func (index *Index) XName(tableName string) string

type LogLevel Uses

type LogLevel int
const (
    // !nashtsai! following level also match syslog.Priority value
    LOG_DEBUG LogLevel = iota
    LOG_INFO
    LOG_WARNING
    LOG_ERR
    LOG_OFF
    LOG_UNKNOWN
)

type NullTime Uses

type NullTime time.Time

func (*NullTime) Scan Uses

func (ns *NullTime) Scan(value interface{}) error

func (NullTime) Value Uses

func (ns NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type PK Uses

type PK []interface{}

func NewPK Uses

func NewPK(pks ...interface{}) *PK

func (*PK) FromString Uses

func (p *PK) FromString(content string) error

func (*PK) ToString Uses

func (p *PK) ToString() (string, error)

type PrefixMapper Uses

type PrefixMapper struct {
    Mapper IMapper
    Prefix string
}

provide prefix table name support

func NewPrefixMapper Uses

func NewPrefixMapper(mapper IMapper, prefix string) PrefixMapper

func (PrefixMapper) Obj2Table Uses

func (mapper PrefixMapper) Obj2Table(name string) string

func (PrefixMapper) Table2Obj Uses

func (mapper PrefixMapper) Table2Obj(name string) string

type QuoteFilter Uses

type QuoteFilter struct {
}

QuoteFilter filter SQL replace ` to database's own quote character

func (*QuoteFilter) Do Uses

func (s *QuoteFilter) Do(sql string, dialect Dialect, table *Table) string

type Quoter Uses

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

func NewQuoter Uses

func NewQuoter(dialect Dialect) *Quoter

func (*Quoter) Quote Uses

func (q *Quoter) Quote(content string) string

type Row Uses

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

func (rs *Rows) ScanMap(dest interface{}) error {

vv := reflect.ValueOf(dest)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map {
	return errors.New("dest should be a map's pointer")
}

cols, err := rs.Columns()
if err != nil {
	return err
}

newDest := make([]interface{}, len(cols))
err = rs.ScanSlice(newDest)
if err != nil {
	return err
}

vvv := vv.Elem()

for i, name := range cols {
	vname := reflect.ValueOf(name)
	vvv.SetMapIndex(vname, reflect.ValueOf(newDest[i]).Elem())
}

return nil

}

func ErrorRow Uses

func ErrorRow(err error) *Row

ErrorRow return an error row

func NewRow Uses

func NewRow(rows *Rows, err error) *Row

NewRow from rows

func (*Row) Columns Uses

func (row *Row) Columns() ([]string, error)

func (*Row) Scan Uses

func (row *Row) Scan(dest ...interface{}) error

func (*Row) ScanMap Uses

func (row *Row) ScanMap(dest interface{}) error

scan data to a map's pointer

func (*Row) ScanSlice Uses

func (row *Row) ScanSlice(dest interface{}) error

scan data to a slice's pointer, slice's length should equal to columns' number

func (*Row) ScanStructByIndex Uses

func (row *Row) ScanStructByIndex(dest interface{}) error

func (*Row) ScanStructByName Uses

func (row *Row) ScanStructByName(dest interface{}) error

func (*Row) ToMapString Uses

func (row *Row) ToMapString() (map[string]string, error)

type Rows Uses

type Rows struct {
    *sql.Rows
    Mapper IMapper
}

func (*Rows) ScanMap Uses

func (rs *Rows) ScanMap(dest interface{}) error

scan data to a map's pointer

func (*Rows) ScanSlice Uses

func (rs *Rows) ScanSlice(dest interface{}) error

scan data to a slice's pointer, slice's length should equal to columns' number

func (*Rows) ScanStructByIndex Uses

func (rs *Rows) ScanStructByIndex(dest ...interface{}) error

scan data to a struct's pointer according field index

func (*Rows) ScanStructByName Uses

func (rs *Rows) ScanStructByName(dest interface{}) error

scan data to a struct's pointer according field name

func (*Rows) ToMapString Uses

func (rs *Rows) ToMapString() ([]map[string]string, error)

type SQLType Uses

type SQLType struct {
    Name           string
    DefaultLength  int
    DefaultLength2 int
}

xorm SQL types

func Type2SQLType Uses

func Type2SQLType(t reflect.Type) (st SQLType)

Type2SQLType generate SQLType acorrding Go's type

func (*SQLType) IsBlob Uses

func (s *SQLType) IsBlob() bool

func (*SQLType) IsJson Uses

func (s *SQLType) IsJson() bool

func (*SQLType) IsNumeric Uses

func (s *SQLType) IsNumeric() bool

func (*SQLType) IsText Uses

func (s *SQLType) IsText() bool

func (*SQLType) IsTime Uses

func (s *SQLType) IsTime() bool

func (*SQLType) IsType Uses

func (s *SQLType) IsType(st int) bool

type SameMapper Uses

type SameMapper struct {
}

SameMapper implements IMapper and provides same name between struct and database table

func (SameMapper) Obj2Table Uses

func (m SameMapper) Obj2Table(o string) string

func (SameMapper) Table2Obj Uses

func (m SameMapper) Table2Obj(t string) string

type SeqFilter Uses

type SeqFilter struct {
    Prefix string
    Start  int
}

SeqFilter filter SQL replace ?, ? ... to $1, $2 ...

func (*SeqFilter) Do Uses

func (s *SeqFilter) Do(sql string, dialect Dialect, table *Table) string

type SnakeMapper Uses

type SnakeMapper struct {
}

SnakeMapper implements IMapper and provides name transaltion between struct and database table

func (SnakeMapper) Obj2Table Uses

func (mapper SnakeMapper) Obj2Table(name string) string

func (SnakeMapper) Table2Obj Uses

func (mapper SnakeMapper) Table2Obj(name string) string

type Stmt Uses

type Stmt struct {
    *sql.Stmt
    Mapper IMapper
    // contains filtered or unexported fields
}

func (*Stmt) ExecMap Uses

func (s *Stmt) ExecMap(mp interface{}) (sql.Result, error)

func (*Stmt) ExecStruct Uses

func (s *Stmt) ExecStruct(st interface{}) (sql.Result, error)

func (*Stmt) Query Uses

func (s *Stmt) Query(args ...interface{}) (*Rows, error)

func (*Stmt) QueryMap Uses

func (s *Stmt) QueryMap(mp interface{}) (*Rows, error)

func (*Stmt) QueryRow Uses

func (s *Stmt) QueryRow(args ...interface{}) *Row

func (*Stmt) QueryRowMap Uses

func (s *Stmt) QueryRowMap(mp interface{}) *Row

func (*Stmt) QueryRowStruct Uses

func (s *Stmt) QueryRowStruct(st interface{}) *Row

func (*Stmt) QueryStruct Uses

func (s *Stmt) QueryStruct(st interface{}) (*Rows, error)

type SuffixMapper Uses

type SuffixMapper struct {
    Mapper IMapper
    Suffix string
}

provide suffix table name support

func NewSuffixMapper Uses

func NewSuffixMapper(mapper IMapper, suffix string) SuffixMapper

func (SuffixMapper) Obj2Table Uses

func (mapper SuffixMapper) Obj2Table(name string) string

func (SuffixMapper) Table2Obj Uses

func (mapper SuffixMapper) Table2Obj(name string) string

type Table Uses

type Table struct {
    Name string
    Type reflect.Type

    Indexes       map[string]*Index
    PrimaryKeys   []string
    AutoIncrement string
    Created       map[string]bool
    Updated       string
    Deleted       string
    Version       string
    Cacher        Cacher
    StoreEngine   string
    Charset       string
    Comment       string
    // contains filtered or unexported fields
}

database table

func NewEmptyTable Uses

func NewEmptyTable() *Table

func NewTable Uses

func NewTable(name string, t reflect.Type) *Table

func (*Table) AddColumn Uses

func (table *Table) AddColumn(col *Column)

add a column to table

func (*Table) AddIndex Uses

func (table *Table) AddIndex(index *Index)

add an index or an unique to table

func (*Table) AutoIncrColumn Uses

func (table *Table) AutoIncrColumn() *Column

func (*Table) ColumnType Uses

func (table *Table) ColumnType(name string) reflect.Type

func (*Table) Columns Uses

func (table *Table) Columns() []*Column

func (*Table) ColumnsSeq Uses

func (table *Table) ColumnsSeq() []string

func (*Table) DeletedColumn Uses

func (table *Table) DeletedColumn() *Column

func (*Table) GetColumn Uses

func (table *Table) GetColumn(name string) *Column

func (*Table) GetColumnIdx Uses

func (table *Table) GetColumnIdx(name string, idx int) *Column

func (*Table) PKColumns Uses

func (table *Table) PKColumns() []*Column

if has primary key, return column

func (*Table) UpdatedColumn Uses

func (table *Table) UpdatedColumn() *Column

func (*Table) VersionColumn Uses

func (table *Table) VersionColumn() *Column

type Tx Uses

type Tx struct {
    *sql.Tx
    Mapper IMapper
}

func (*Tx) ExecMap Uses

func (tx *Tx) ExecMap(query string, mp interface{}) (sql.Result, error)

func (*Tx) ExecStruct Uses

func (tx *Tx) ExecStruct(query string, st interface{}) (sql.Result, error)

func (*Tx) Prepare Uses

func (tx *Tx) Prepare(query string) (*Stmt, error)

func (*Tx) Query Uses

func (tx *Tx) Query(query string, args ...interface{}) (*Rows, error)

func (*Tx) QueryMap Uses

func (tx *Tx) QueryMap(query string, mp interface{}) (*Rows, error)

func (*Tx) QueryRow Uses

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

func (*Tx) QueryRowMap Uses

func (tx *Tx) QueryRowMap(query string, mp interface{}) *Row

func (*Tx) QueryRowStruct Uses

func (tx *Tx) QueryRowStruct(query string, st interface{}) *Row

func (*Tx) QueryStruct Uses

func (tx *Tx) QueryStruct(query string, st interface{}) (*Rows, error)

func (*Tx) Stmt Uses

func (tx *Tx) Stmt(stmt *Stmt) *Stmt

type Uri Uses

type Uri struct {
    DbType  DbType
    Proto   string
    Host    string
    Port    string
    DbName  string
    User    string
    Passwd  string
    Charset string
    Laddr   string
    Raddr   string
    Timeout time.Duration
    Schema  string
}

Package core imports 12 packages (graph) and is imported by 382 packages. Updated 2017-12-07. Refresh now. Tools for package owners.