Documentation
¶
Index ¶
- Constants
- Variables
- func MapToSlice(query string, mp interface{}) (string, []interface{}, error)
- func StructToSlice(query string, st interface{}) (string, []interface{}, error)
- type CondQuery
- type Conn
- type Conversion
- type ExecQuery
- type Executor
- type Logger
- type Model
- func (m *Model) Bind(query Query) Query
- func (m *Model) Count(query Query) (int64, error)
- func (m *Model) CountByQuery(query Query) (int64, error)
- func (m *Model) Delete(query Query) (int64, error)
- func (m *Model) DeleteByQuery(query Query) (int64, error)
- func (m *Model) Find(query Query) ([]interface{}, error)
- func (m *Model) FindByQuery(query Query) ([]interface{}, error)
- func (m *Model) Insert(record interface{}) (int64, error)
- func (m *Model) One(query Query) (interface{}, error)
- func (m *Model) PK(key ...interface{}) ModelQuery
- func (m *Model) Query() ModelQuery
- func (m *Model) Rows(query Query) (Rows, error)
- func (m *Model) Update(query Query, record interface{}) (int64, error)
- func (m *Model) UpdateByQuery(query Query, record interface{}) (int64, error)
- type ModelQuery
- type Query
- type RawBytes
- type Rows
- type Schema
- func (s *Schema) Default(field string, value interface{}) *Schema
- func (s *Schema) Emit(event string, record interface{}) error
- func (s *Schema) Get(record interface{}, field string) (interface{}, error)
- func (s *Schema) On(event string, f func(record interface{}) error) error
- func (s *Schema) Set(record interface{}, field string, v interface{}) error
- func (s *Schema) SetAutoIncrement(field string) *Schema
- func (s *Schema) SetCreateTime(createTime string) *Schema
- func (s *Schema) SetPrimary(primary ...string) *Schema
- func (s *Schema) SetTime(createTime string, updateTime string, deleteTime string) *Schema
- func (s *Schema) SetUpdateTime(updateTime string) *Schema
- func (s *Schema) SoftDelete(deleteTime string) *Schema
- func (s *Schema) With(record interface{}) error
- type SelectQuery
- type Transaction
Constants ¶
View Source
const ( POSTGRES = "postgres" SQLITE = "sqlite3" MYSQL = "mysql" MSSQL = "mssql" ORACLE = "oracle" )
View Source
const ( UNKNOW_TYPE = iota TEXT_TYPE BLOB_TYPE TIME_TYPE NUMERIC_TYPE )
Variables ¶
View Source
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, } )
View Source
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) )
View Source
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) )
Functions ¶
func MapToSlice ¶
func StructToSlice ¶
Types ¶
type CondQuery ¶
type CondQuery interface { Table(table string) Query TableAlias(table string, alias string) Query Field(field string) Query FieldAlias(field string, alias string) Query Where(field string, operate string, value interface{}) Query Limit(start int, offset int) Query Page(page int, size int) Query Order(field string) Query Asc(field string) Query Desc(field string) Query Sql(query string, args interface{}) Query }
type Executor ¶
type Executor interface { Conn(conn *sql.DB) ConnWithDriver(conn *sql.DB, driver string) Query() Query Session(f func(conn Conn) error) error Begin() (Transaction, error) }
func DefaultExecutor ¶
func DefaultExecutor() Executor
func NewExecutor ¶
func NewExecutor() Executor
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func NewModelWithSchema ¶
func (*Model) FindByQuery ¶
func (*Model) PK ¶
func (m *Model) PK(key ...interface{}) ModelQuery
func (*Model) Query ¶
func (m *Model) Query() ModelQuery
type ModelQuery ¶
type Schema ¶
type Schema struct { AutoIncrement string Primary []string // contains filtered or unexported fields }
func (*Schema) SetAutoIncrement ¶
func (*Schema) SetCreateTime ¶
func (*Schema) SetPrimary ¶
func (*Schema) SetUpdateTime ¶
func (*Schema) SoftDelete ¶
type SelectQuery ¶
type Transaction ¶
Click to show internal directories.
Click to hide internal directories.