db

package
v0.0.0-...-de310a9 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(rec Rec, src Source) error

func Store

func Store(rec Rec) error

Types

type BasicCol

type BasicCol struct {
	BasicDef
	BasicField
	// contains filtered or unexported fields
}

func (*BasicCol) Create

func (self *BasicCol) Create(table Table) error

func (*BasicCol) Drop

func (self *BasicCol) Drop(table Table) error

func (*BasicCol) Eq

func (self *BasicCol) Eq(r interface{}) Cond

func (*BasicCol) EqCol

func (self *BasicCol) EqCol(r Col) Cond

func (*BasicCol) ForeignKey

func (self *BasicCol) ForeignKey() *ForeignKey

func (*BasicCol) GetFieldAddr

func (self *BasicCol) GetFieldAddr(rec Ref) interface{}

func (*BasicCol) GetFieldValue

func (self *BasicCol) GetFieldValue(rec Ref) interface{}

func (*BasicCol) Gt

func (self *BasicCol) Gt(r interface{}) Cond

func (*BasicCol) Init

func (self *BasicCol) Init(table Table, name string)

func (*BasicCol) IsPrimaryKey

func (self *BasicCol) IsPrimaryKey() bool

func (*BasicCol) Lt

func (self *BasicCol) Lt(r interface{}) Cond

func (*BasicCol) Op

func (self *BasicCol) Op(op string, r interface{}) Cond

func (*BasicCol) SetFieldValue

func (self *BasicCol) SetFieldValue(rec Ref, val interface{})

func (*BasicCol) SetPrimaryKey

func (self *BasicCol) SetPrimaryKey(val bool)

func (*BasicCol) ValParams

func (self *BasicCol) ValParams() []interface{}

func (*BasicCol) WriteValSql

func (self *BasicCol) WriteValSql(out io.Writer) error

type BasicCols

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

func (*BasicCols) AddCol

func (self *BasicCols) AddCol(cols ...Col)

func (*BasicCols) Cols

func (self *BasicCols) Cols() []Col

func (*BasicCols) FindCol

func (self *BasicCols) FindCol(name string) Col

func (*BasicCols) Init

func (self *BasicCols) Init()

func (*BasicCols) SetPrimaryKey

func (self *BasicCols) SetPrimaryKey(val bool)

type BasicDef

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

func (*BasicDef) Init

func (self *BasicDef) Init(name string)

func (*BasicDef) Name

func (self *BasicDef) Name() string

type BasicField

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

func (*BasicField) FieldName

func (self *BasicField) FieldName() string

func (*BasicField) GetField

func (self *BasicField) GetField(rec Ref) reflect.Value

func (*BasicField) GetFieldAddr

func (self *BasicField) GetFieldAddr(rec Ref) interface{}

func (*BasicField) GetFieldValue

func (self *BasicField) GetFieldValue(rec Ref) interface{}

func (*BasicField) Init

func (self *BasicField) Init(fieldName string)

func (*BasicField) SetFieldValue

func (self *BasicField) SetFieldValue(rec Ref, val interface{})

type BasicRec

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

func (*BasicRec) AfterInsert

func (self *BasicRec) AfterInsert() error

func (*BasicRec) Cx

func (self *BasicRec) Cx() *Cx

func (*BasicRec) DoInsert

func (self *BasicRec) DoInsert(rec Rec) error

func (*BasicRec) DoUpdate

func (self *BasicRec) DoUpdate(rec Rec) error

func (*BasicRec) Init

func (self *BasicRec) Init(cx *Cx)

type BasicTable

type BasicTable struct {
	BasicCols
	BasicDef
	// contains filtered or unexported fields
}

func (*BasicTable) Create

func (self *BasicTable) Create() error

func (*BasicTable) Cx

func (self *BasicTable) Cx() *Cx

func (*BasicTable) Drop

func (self *BasicTable) Drop() error

func (*BasicTable) Exists

func (self *BasicTable) Exists() (bool, error)

func (*BasicTable) FindForeignKey

func (self *BasicTable) FindForeignKey(name string) *ForeignKey

func (*BasicTable) Init

func (self *BasicTable) Init(cx *Cx, name string) *BasicTable

func (*BasicTable) Insert

func (self *BasicTable) Insert(rec Rec) error

func (*BasicTable) Load

func (self *BasicTable) Load(rec Rec) error

func (*BasicTable) LoadFields

func (self *BasicTable) LoadFields(rec Rec, src Source) error

func (*BasicTable) NewEnumCol

func (self *BasicTable) NewEnumCol(name string, enum *Enum) *EnumCol

func (*BasicTable) NewForeignKey

func (self *BasicTable) NewForeignKey(name string, foreignTable Table) *ForeignKey

func (*BasicTable) NewIntCol

func (self *BasicTable) NewIntCol(name string) *IntCol

func (*BasicTable) NewStoredRec

func (self *BasicTable) NewStoredRec() StoredRec

func (*BasicTable) NewStringCol

func (self *BasicTable) NewStringCol(name string) *StringCol

func (*BasicTable) NewTimeCol

func (self *BasicTable) NewTimeCol(name string) *TimeCol

func (*BasicTable) PrimaryKey

func (self *BasicTable) PrimaryKey() *Key

func (*BasicTable) Query

func (self *BasicTable) Query() *Query

func (*BasicTable) RelParams

func (self *BasicTable) RelParams() []interface{}

func (*BasicTable) StoredRec

func (self *BasicTable) StoredRec(rec Rec) StoredRec

func (*BasicTable) Update

func (self *BasicTable) Update(rec Rec) error

func (*BasicTable) WriteRelSql

func (self *BasicTable) WriteRelSql(out io.Writer) error

type Col

type Col interface {
	Field
	TableDef
	Val

	NewForeignCol(table Table, name string, key *ForeignKey) Col
	NewField() interface{}
	ValType() string
	IsPrimaryKey() bool
	SetPrimaryKey(bool)
	ForeignKey() *ForeignKey
	EqCol(r Col) Cond
	Eq(r interface{}) Cond
	Lt(r interface{}) Cond
	Gt(r interface{}) Cond
}

type Cols

type Cols interface {
	Cols() []Col
	AddCol(cols ...Col)
	FindCol(name string) Col
	SetPrimaryKey(val bool)
}

type Cond

type Cond interface {
	WriteCondSql(out io.Writer) error
	CondParams() []interface{}
}

func NewCond

func NewCond(sql string, params ...interface{}) Cond

type CustomCond

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

func (*CustomCond) CondParams

func (self *CustomCond) CondParams() []interface{}

func (*CustomCond) Init

func (self *CustomCond) Init(sql string, params ...interface{}) *CustomCond

func (*CustomCond) WriteCondSql

func (self *CustomCond) WriteCondSql(out io.Writer) error

type CustomVal

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

func (*CustomVal) Init

func (self *CustomVal) Init(sql string, params ...interface{}) *CustomVal

func (*CustomVal) ValParams

func (self *CustomVal) ValParams() []interface{}

func (*CustomVal) WriteValSql

func (self *CustomVal) WriteValSql(out io.Writer) error

type Cx

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

func NewCx

func NewCx(conn *pgx.Conn) *Cx

func (*Cx) DropAll

func (self *Cx) DropAll() error

func (*Cx) ExecSQL

func (self *Cx) ExecSQL(sql string, params ...interface{}) error

func (*Cx) FindTable

func (self *Cx) FindTable(name string) Table

func (*Cx) Init

func (self *Cx) Init(conn *pgx.Conn) *Cx

func (*Cx) NewEnum

func (self *Cx) NewEnum(name string, alts ...string) *Enum

func (*Cx) NewTable

func (self *Cx) NewTable(name string) Table

func (*Cx) Query

func (self *Cx) Query(sql string, params ...interface{}) (pgx.Rows, error)

func (*Cx) QueryRow

func (self *Cx) QueryRow(sql string, params ...interface{}) pgx.Row

func (*Cx) SyncAll

func (self *Cx) SyncAll() error

type Def

type Def interface {
	Name() string
}

type Enum

type Enum struct {
	BasicDef
	// contains filtered or unexported fields
}

func NewEnum

func NewEnum(cx *Cx, name string, alts ...string) *Enum

func (*Enum) Create

func (self *Enum) Create() error

func (*Enum) Drop

func (self *Enum) Drop() error

func (*Enum) Exists

func (self *Enum) Exists() (bool, error)

func (*Enum) Init

func (self *Enum) Init(cx *Cx, name string, alts ...string) *Enum

type EnumCol

type EnumCol struct {
	BasicCol
	// contains filtered or unexported fields
}

func (*EnumCol) Init

func (self *EnumCol) Init(table Table, name string, enum *Enum) *EnumCol

func (*EnumCol) NewField

func (self *EnumCol) NewField() interface{}

func (*EnumCol) NewForeignCol

func (self *EnumCol) NewForeignCol(table Table, name string, key *ForeignKey) Col

func (*EnumCol) ValType

func (self *EnumCol) ValType() string

type Field

type Field interface {
	FieldName() string
	GetField(rec Ref) reflect.Value
	GetFieldAddr(rec Ref) interface{}
	GetFieldValue(rec Ref) interface{}
	SetFieldValue(rec Ref, val interface{})
}

type ForeignKey

type ForeignKey struct {
	BasicField
	Key
	// contains filtered or unexported fields
}

func (*ForeignKey) Create

func (self *ForeignKey) Create(table Table) error

func (*ForeignKey) ForeignTable

func (self *ForeignKey) ForeignTable() Table

func (*ForeignKey) Init

func (self *ForeignKey) Init(name string, fieldName string, foreignTable Table) *ForeignKey

type IntCol

type IntCol struct {
	BasicCol
}

func (*IntCol) Init

func (self *IntCol) Init(table Table, name string) *IntCol

func (*IntCol) NewField

func (self *IntCol) NewField() interface{}

func (*IntCol) NewForeignCol

func (self *IntCol) NewForeignCol(table Table, name string, key *ForeignKey) Col

func (*IntCol) ValType

func (self *IntCol) ValType() string

type Join

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

func NewJoin

func NewJoin(left Rel, right Rel, conds ...Cond) *Join

func (*Join) Init

func (self *Join) Init(left Rel, right Rel, conds ...Cond) *Join

func (*Join) RelParams

func (self *Join) RelParams() []interface{}

func (*Join) WriteRelSql

func (self *Join) WriteRelSql(sql io.Writer) error

type Key

type Key struct {
	BasicCols
	BasicDef
}

func NewKey

func NewKey(name string, cols ...Col) *Key

func (*Key) Create

func (self *Key) Create(table Table) error

func (*Key) Drop

func (self *Key) Drop(table Table) error

func (*Key) Init

func (self *Key) Init(name string, cols ...Col) *Key

type Query

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

func NewQuery

func NewQuery(cx *Cx) *Query

func (*Query) Close

func (self *Query) Close()

func (*Query) Cx

func (self *Query) Cx() *Cx

func (*Query) From

func (self *Query) From(rel Rel) *Query

func (*Query) Init

func (self *Query) Init(cx *Cx) *Query

func (*Query) Join

func (self *Query) Join(right Table, key *ForeignKey) *Query

func (*Query) Join2

func (self *Query) Join2(right Table, key1, key2 *ForeignKey) *Query

func (*Query) Next

func (self *Query) Next() bool

func (*Query) OrderBy

func (self *Query) OrderBy(in ...Val) *Query

func (*Query) Run

func (self *Query) Run() error

func (*Query) Scan

func (self *Query) Scan(dst ...interface{}) error

func (*Query) Select

func (self *Query) Select(in ...Val) *Query

func (*Query) Where

func (self *Query) Where(in ...Cond) *Query

type Rec

type Rec interface {
	Ref
	AfterInsert() error
	DoInsert(rec Rec) error
	DoUpdate(rec Rec) error
}

type RecProxy

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

func NewRecProxy

func NewRecProxy(table Table) *RecProxy

func (*RecProxy) Exists

func (self *RecProxy) Exists() bool

func (*RecProxy) Init

func (self *RecProxy) Init(table Table) *RecProxy

func (*RecProxy) KeyVals

func (self *RecProxy) KeyVals() []interface{}

func (*RecProxy) Load

func (self *RecProxy) Load(rec Rec) (Rec, error)

func (*RecProxy) Table

func (self *RecProxy) Table() Table

type Ref

type Ref interface {
	Table() Table
}

type Rel

type Rel interface {
	WriteRelSql(out io.Writer) error
	RelParams() []interface{}
}

type RootDef

type RootDef interface {
	Def
	Create() error
	Exists() (bool, error)
	Drop() error
}

type Source

type Source interface {
	Scan(dst ...interface{}) error
}

type StoredRec

type StoredRec = []interface{}

type StringCol

type StringCol struct {
	BasicCol
}

func (*StringCol) Init

func (self *StringCol) Init(table Table, name string) *StringCol

func (*StringCol) NewField

func (self *StringCol) NewField() interface{}

func (*StringCol) NewForeignCol

func (self *StringCol) NewForeignCol(table Table, name string, key *ForeignKey) Col

func (*StringCol) ValType

func (self *StringCol) ValType() string

type Table

type Table interface {
	Cols
	RootDef
	Rel

	Cx() *Cx
	PrimaryKey() *Key

	NewForeignKey(name string, foreignTable Table) *ForeignKey
	FindForeignKey(name string) *ForeignKey

	NewEnumCol(name string, enum *Enum) *EnumCol
	NewIntCol(name string) *IntCol
	NewStringCol(name string) *StringCol
	NewTimeCol(name string) *TimeCol

	NewStoredRec() StoredRec
	StoredRec(rec Rec) StoredRec
	Insert(rec Rec) error
	Update(rec Rec) error
	LoadFields(rec Rec, src Source) error
	Load(rec Rec) error
	Query() *Query
}

type TableDef

type TableDef interface {
	Def
	Create(table Table) error
	Drop(table Table) error
}

type TimeCol

type TimeCol struct {
	BasicCol
}

func (*TimeCol) Init

func (self *TimeCol) Init(table Table, name string) *TimeCol

func (*TimeCol) NewField

func (self *TimeCol) NewField() interface{}

func (*TimeCol) NewForeignCol

func (self *TimeCol) NewForeignCol(table Table, name string, key *ForeignKey) Col

func (*TimeCol) ValType

func (self *TimeCol) ValType() string

type Val

type Val interface {
	WriteValSql(out io.Writer) error
	ValParams() []interface{}
}

func NewVal

func NewVal(sql string, params ...interface{}) Val

Jump to

Keyboard shortcuts

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