Documentation ¶
Index ¶
- Constants
- func Camel2Underscore(s string) string
- func DefaultDeclare(f reflect.StructField, props PropertySet) (string, error)
- func ParseDottedArgs(s string) (ret []string)
- func RegisterDialect(name string, d IDialect)
- type BigInteger
- type BigSerial
- type Bit
- type Bitvar
- type Boolean
- type Bytea
- type Char
- type Column
- type ConditionType
- type Constraint
- type Date
- type Decimal
- type Declarable
- type Double
- type Engine
- type Enum
- type IDialect
- type Index
- type Integer
- type Interval
- type Numeric
- type OrderType
- type PropertySet
- func (h PropertySet) GetBool(k string, defaults ...bool) (bool, bool)
- func (h PropertySet) GetInt(k string, defaults ...int) (int, bool)
- func (h PropertySet) GetInt64(k string, defaults ...int64) (int64, bool)
- func (h PropertySet) GetString(k string, defaults ...string) (string, bool)
- func (h PropertySet) GetUInt(k string, defaults ...uint) (uint, bool)
- func (h PropertySet) HasKey(k string) bool
- func (h PropertySet) PopBool(k string, defaults ...bool) (bool, bool)
- func (h PropertySet) PopInt(k string, defaults ...int) (int, bool)
- func (h PropertySet) PopInt64(k string, defaults ...int64) (int64, bool)
- func (h PropertySet) PopString(k string, defaults ...string) (string, bool)
- func (h PropertySet) PopUInt(k string, defaults ...uint) (uint, bool)
- type QueryColumn
- type QueryExtra
- type QueryFilter
- type QueryOrder
- type QuerySet
- func (qs QuerySet) All() (*XRows, error)
- func (qs QuerySet) And(field string, val interface{}, ops ...string) QuerySet
- func (qs QuerySet) Count(cols ...string) (int64, error)
- func (qs QuerySet) Delete() (int64, error)
- func (qs QuerySet) Filter(cons ...interface{}) QuerySet
- func (qs QuerySet) Get(pks ...interface{}) *XRow
- func (qs QuerySet) Insert(objs ...interface{}) (int64, error)
- func (qs QuerySet) InsertWithInsertedId(obj interface{}, idname string, id interface{}) error
- func (qs QuerySet) Limit(limit int64) QuerySet
- func (qs QuerySet) LockFor(s string) QuerySet
- func (qs QuerySet) Offset(offset int64) QuerySet
- func (qs QuerySet) One() *XRow
- func (qs QuerySet) Or(field string, val interface{}, ops ...string) QuerySet
- func (qs QuerySet) OrderBy(orders ...interface{}) QuerySet
- func (qs QuerySet) Update(vals interface{}) (int64, error)
- func (qs QuerySet) Where(field string, val interface{}, ops ...string) QuerySet
- type Real
- type Serial
- type Session
- func (session *Session) Begin() error
- func (session *Session) Close()
- func (session *Session) Commit() error
- func (session *Session) Create(table *Table) error
- func (session *Session) Drop(table *Table, force bool) error
- func (session *Session) Exec(query string, args ...interface{}) (sql.Result, error)
- func (session *Session) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (session *Session) QueryRow(query string, args ...interface{}) *sql.Row
- func (session *Session) Rollback() error
- func (session *Session) Table(table *Table, columns ...interface{}) QuerySet
- type SmallInteger
- type SmallSerial
- type Table
- func (t *Table) BaseTableName() string
- func (t *Table) GetColumn(name string) (*Column, bool)
- func (t *Table) GetColumns() []*Column
- func (t *Table) GetConstraints() []*Constraint
- func (t *Table) GetIndexes() []*Index
- func (t *Table) GetPrimaryKeys() []*Column
- func (t *Table) Schema() string
- func (t *Table) SetSchema(s string)
- func (t *Table) TableName() string
- type TableConstrained
- type TableCreatable
- type TableDeletable
- type TableIdentified
- type TableIgnored
- type TableIndexed
- type TablePostDelete
- type TablePostInsert
- type TablePostUpdate
- type TablePreDelete
- type TablePreInsert
- type TablePreUpdate
- type TableReadable
- type TableUpdatable
- type Text
- type Time
- type TimeStamp
- type UUID
- type UpdateColumn
- type Varchar
- type XRow
- type XRows
Constants ¶
const ( ConstraintNone uint8 = iota ConstraintCheck ConstraintNotNull ConstraintUnique ConstraintPrimaryKey ConstraintForeignKey ConstraintExclude ConstraintInvalid )
const ( IndexNone uint8 = iota IndexBTree IndexHash IndexGist IndexSpGist IndexGin IndexBrin IndexInvalid )
PostgreSQL provides several index types: B-tree, Hash, GiST, SP-GiST, GIN and BRIN
Variables ¶
This section is empty.
Functions ¶
func Camel2Underscore ¶
func DefaultDeclare ¶ added in v0.2.1
func DefaultDeclare(f reflect.StructField, props PropertySet) (string, error)
func ParseDottedArgs ¶ added in v0.5.1
func RegisterDialect ¶
Types ¶
type BigInteger ¶ added in v0.2.1
type BigInteger int64
bigint 8 bytes large-range integer -9223372036854775808 to +9223372036854775807
func (BigInteger) Declare ¶ added in v0.2.1
func (s BigInteger) Declare(props PropertySet) string
type BigSerial ¶ added in v0.2.1
type BigSerial uint64
bigserial 8 bytes large autoincrementing integer 1 to 9223372036854775807
func (BigSerial) Declare ¶ added in v0.2.1
func (s BigSerial) Declare(props PropertySet) string
type Bit ¶ added in v0.2.1
type Bit string
func (Bit) Declare ¶ added in v0.2.1
func (b Bit) Declare(props PropertySet) string
type Bitvar ¶ added in v0.2.1
type Bitvar string
func (Bitvar) Declare ¶ added in v0.2.1
func (b Bitvar) Declare(props PropertySet) string
type Boolean ¶ added in v0.2.1
type Boolean bool
Boolean Data Type
Name Storage Size Description boolean 1 byte state of true or false
func (Boolean) Declare ¶ added in v0.2.1
func (s Boolean) Declare(props PropertySet) string
type Bytea ¶ added in v0.2.1
type Bytea []byte
Binary Data Types
Name Storage Size Description bytea 1 or 4 bytes plus the actual binary string variable-length binary string
func (Bytea) Declare ¶ added in v0.2.1
func (b Bytea) Declare(props PropertySet) string
type Char ¶ added in v0.2.1
type Char string
character(n), char(n) fixed-length, blank padded
func (Char) Declare ¶ added in v0.2.1
func (s Char) Declare(props PropertySet) string
type Column ¶
type Column struct { PropertySet FieldName string ElemName string JTag string Type reflect.Type TypeDefine string Indexed bool // Indexed or not, on field Nullable bool // Nullable constraint on field Unique bool // Unique constraint on field PrimaryKey bool //Primary Key constraint on field Default interface{} Constraints []*Constraint Indexes []*Index // contains filtered or unexported fields }
type ConditionType ¶
type ConditionType uint
const ( ConditionAnd ConditionType = iota ConditionOr )
type Constraint ¶ added in v0.2.1
type Date ¶ added in v0.2.1
date 4 bytes date (no time of day) 4713 BC 5874897 AD 1 day
func (Date) Declare ¶ added in v0.2.1
func (s Date) Declare(props PropertySet) string
type Decimal ¶ added in v0.2.1
type Decimal string
decimal variable user-specified precision, exact up to 131072 digits before the decimal point; up to 16383 digits after the decimal point
func (Decimal) Declare ¶ added in v0.2.1
func (d Decimal) Declare(props PropertySet) string
type Declarable ¶ added in v0.2.1
type Declarable interface {
Declare(props PropertySet) string
}
type Double ¶ added in v0.2.1
type Double float64
double precision 8 bytes variable-precision, inexact 15 decimal digits precision
func (Double) Declare ¶ added in v0.2.1
func (s Double) Declare(props PropertySet) string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (Engine) DriverName ¶ added in v0.2.11
func (*Engine) MakeSession ¶
type Enum ¶ added in v0.2.1
type Enum string
CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
func (Enum) Declare ¶ added in v0.2.1
func (s Enum) Declare(props PropertySet) string
type IDialect ¶
type IDialect interface { Create(*Table, ...interface{}) (string, []interface{}, error) Drop(*Table, bool) (string, []interface{}, error) Select(*Table, []QueryColumn, []QueryFilter, []QueryOrder, string, int64, int64) (string, []interface{}, error) Insert(*Table, interface{}, ...string) (string, []interface{}, error) InsertWithInsertedId(*Table, interface{}, string, ...string) (string, []interface{}, error) Update(*Table, []QueryFilter, ...UpdateColumn) (string, []interface{}, error) Delete(*Table, []QueryFilter) (string, []interface{}, error) }
type Integer ¶ added in v0.2.1
type Integer int
integer 4 bytes typical choice for integer -2147483648 to +2147483647
func (Integer) Declare ¶ added in v0.2.1
func (s Integer) Declare(props PropertySet) string
type Interval ¶ added in v0.2.1
interval [ columns ] [ (p) ] 16 bytes time interval -178000000 years 178000000 years 1 microsecond / 14 digits
func (Interval) Declare ¶ added in v0.2.1
func (s Interval) Declare(props PropertySet) string
type Numeric ¶ added in v0.2.1
type Numeric Decimal
numeric variable user-specified precision, exact up to 131072 digits before the decimal point; up to 16383 digits after the decimal point
type PropertySet ¶ added in v0.2.1
func ParseProperties ¶ added in v0.2.1
func ParseProperties(s string) (PropertySet, error)
func (PropertySet) GetBool ¶ added in v0.2.1
func (h PropertySet) GetBool(k string, defaults ...bool) (bool, bool)
func (PropertySet) GetInt ¶ added in v0.2.1
func (h PropertySet) GetInt(k string, defaults ...int) (int, bool)
func (PropertySet) GetInt64 ¶ added in v0.2.1
func (h PropertySet) GetInt64(k string, defaults ...int64) (int64, bool)
func (PropertySet) GetString ¶ added in v0.2.1
func (h PropertySet) GetString(k string, defaults ...string) (string, bool)
func (PropertySet) GetUInt ¶ added in v0.2.1
func (h PropertySet) GetUInt(k string, defaults ...uint) (uint, bool)
func (PropertySet) HasKey ¶ added in v0.2.1
func (h PropertySet) HasKey(k string) bool
func (PropertySet) PopBool ¶ added in v0.2.1
func (h PropertySet) PopBool(k string, defaults ...bool) (bool, bool)
func (PropertySet) PopInt ¶ added in v0.2.1
func (h PropertySet) PopInt(k string, defaults ...int) (int, bool)
func (PropertySet) PopInt64 ¶ added in v0.2.1
func (h PropertySet) PopInt64(k string, defaults ...int64) (int64, bool)
type QueryColumn ¶
func (QueryColumn) String ¶
func (qc QueryColumn) String(as ...bool) string
type QueryExtra ¶ added in v0.4.8
type QueryExtra map[string]interface{}
type QueryFilter ¶
type QueryFilter struct { Condition ConditionType // AND , OR Reversed bool // Reversed Column and Value if it is true Field string Operator string // Value will not used if empty. Function string Value interface{} }
func Where ¶ added in v0.3.1
func Where(field string, val interface{}, ops ...string) QueryFilter
type QueryOrder ¶
type QuerySet ¶
type QuerySet struct {
// contains filtered or unexported fields
}
func (QuerySet) InsertWithInsertedId ¶ added in v0.2.11
type Real ¶ added in v0.2.1
type Real float32
real 4 bytes variable-precision, inexact 6 decimal digits precision
func (Real) Declare ¶ added in v0.2.1
func (s Real) Declare(props PropertySet) string
type Serial ¶ added in v0.2.1
type Serial uint
serial 4 bytes autoincrementing integer 1 to 2147483647
func (Serial) Declare ¶ added in v0.2.1
func (s Serial) Declare(props PropertySet) string
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
type SmallInteger ¶ added in v0.2.1
type SmallInteger int16
Name Storage Size Description Range type TinyInteger int8
func (s TinyInteger) Declare(props PropertySet) string { return "TINYINT" }
smallint 2 bytes small-range integer -32768 to +32767
func (SmallInteger) Declare ¶ added in v0.2.1
func (s SmallInteger) Declare(props PropertySet) string
type SmallSerial ¶ added in v0.2.1
type SmallSerial uint16
type TinySerial uint8
func (s TinySerial) Declare(props PropertySet) string { return "TINYSERIAL" }
smallserial 2 bytes small autoincrementing integer 1 to 32767
func (SmallSerial) Declare ¶ added in v0.2.1
func (s SmallSerial) Declare(props PropertySet) string
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table ... Struct defined for a table object.
func DeclareTable ¶
func DeclareTable(entity TableIdentified, schema ...string) *Table
DeclareTable Which declare a new Table instance according to a given entity.
func (*Table) BaseTableName ¶ added in v0.2.1
func (*Table) GetColumns ¶ added in v0.2.1
func (*Table) GetConstraints ¶ added in v0.2.1
func (t *Table) GetConstraints() []*Constraint
func (*Table) GetIndexes ¶ added in v0.2.1
func (*Table) GetPrimaryKeys ¶ added in v0.2.2
type TableConstrained ¶ added in v0.5.1
type TableConstrained interface {
Constraints() [][3]string
}
TableConstrained Which allow struct to define a method Constraints() to customize table constraints type, fields, statement
type TableCreatable ¶ added in v0.2.14
type TableCreatable interface {
Creatable() bool
}
type TableDeletable ¶ added in v0.2.14
type TableDeletable interface {
Deletable() bool
}
type TableIdentified ¶ added in v0.2.1
type TableIdentified interface {
TableName() string
}
TableIdentified which make sure struct have a method TableName() This is mandatory for a struct can use as Table structure.
type TableIgnored ¶ added in v0.2.1
type TableIgnored interface {
Ignore() []string
}
TableIgnored Which allow struct to define a method Ignore() to tell ignore elements for table columns
type TableIndexed ¶ added in v0.2.1
type TableIndexed interface {
Indexes() [][2]string
}
TableIndexed Which allow struct to define a method Indexes() to define table indexes type, fields, statement
type TablePostDelete ¶ added in v0.2.1
type TablePostInsert ¶ added in v0.2.1
type TablePostUpdate ¶ added in v0.2.1
type TablePreDelete ¶ added in v0.2.1
type TablePreInsert ¶ added in v0.2.1
TablePreInsert Which entity implemented will be called when xql create a new struct instance.
type TablePreUpdate ¶ added in v0.2.6
type TableReadable ¶ added in v0.2.14
type TableReadable interface {
Readable() bool
}
type TableUpdatable ¶ added in v0.2.14
type TableUpdatable interface {
Updatable() bool
}
type Text ¶ added in v0.2.1
type Text string
text variable unlimited length
func (Text) Declare ¶ added in v0.2.1
func (s Text) Declare(props PropertySet) string
type Time ¶ added in v0.2.1
time [ (p) ] [ without time zone ] 8 bytes time of day (no date) 00:00:00 24:00:00 1 microsecond / 14 digits time [ (p) ] with time zone 12 bytes times of day only, with time zone 00:00:00+1459 24:00:00-1459 1 microsecond / 14 digits
func (Time) Declare ¶ added in v0.2.1
func (s Time) Declare(props PropertySet) string
type TimeStamp ¶ added in v0.2.1
Date/Time Types
Name Storage Size Description Low Value High Value Resolution timestamp [ (p) ] [ without time zone ] 8 bytes both date and time (no time zone) 4713 BC 294276 AD 1 microsecond / 14 digits timestamp [ (p) ] with time zone 8 bytes both date and time, with time zone 4713 BC 294276 AD 1 microsecond / 14 digits
func (TimeStamp) Declare ¶ added in v0.2.1
func (s TimeStamp) Declare(props PropertySet) string
type UUID ¶ added in v0.2.1
type UUID string
UUID Type
func (UUID) Declare ¶ added in v0.2.1
func (s UUID) Declare(props PropertySet) string
type UpdateColumn ¶
type Varchar ¶ added in v0.2.1
type Varchar string
Name Description character varying(n), varchar(n) variable-length with limit
func (Varchar) Declare ¶ added in v0.2.1
func (s Varchar) Declare(props PropertySet) string