Documentation
¶
Index ¶
- Constants
- Variables
- func IsAutoIncrement(f XFieldDef) bool
- func IsFieldConstraint(f XFieldDef, ftype string) bool
- func IsNotNull(f XFieldDef) bool
- func IsPrimaryKey(f XFieldDef) bool
- type Cursor
- type XBase
- type XCondition
- type XConditions
- type XConstraint
- type XConstraints
- type XFieldDate
- func (f XFieldDate) CreateField(prepend string, DB string, ifText *bool) string
- func (f XFieldDate) CreateIndex(table string, id string, DB string) []string
- func (f XFieldDate) CreateSequence(table string) string
- func (f XFieldDate) CreateValue(v interface{}, table string, DB string, id string) string
- func (f XFieldDate) GetConstraints() XConstraints
- func (f XFieldDate) GetName() string
- func (f XFieldDate) GetType() int
- type XFieldDateTime
- func (f XFieldDateTime) CreateField(prepend string, DB string, ifText *bool) string
- func (f XFieldDateTime) CreateIndex(table string, id string, DB string) []string
- func (f XFieldDateTime) CreateSequence(table string) string
- func (f XFieldDateTime) CreateValue(v interface{}, table string, DB string, id string) string
- func (f XFieldDateTime) GetConstraints() XConstraints
- func (f XFieldDateTime) GetName() string
- func (f XFieldDateTime) GetType() int
- type XFieldDef
- type XFieldFloat
- func (f XFieldFloat) CreateField(prepend string, DB string, ifText *bool) string
- func (f XFieldFloat) CreateIndex(table string, id string, DB string) []string
- func (f XFieldFloat) CreateSequence(table string) string
- func (f XFieldFloat) CreateValue(v interface{}, table string, DB string, id string) string
- func (f XFieldFloat) GetConstraints() XConstraints
- func (f XFieldFloat) GetName() string
- func (f XFieldFloat) GetType() int
- type XFieldInteger
- func (f XFieldInteger) CreateField(prepend string, DB string, ifText *bool) string
- func (f XFieldInteger) CreateIndex(table string, id string, DB string) []string
- func (f XFieldInteger) CreateSequence(table string) string
- func (f XFieldInteger) CreateValue(v interface{}, table string, DB string, id string) string
- func (f XFieldInteger) GetConstraints() XConstraints
- func (f XFieldInteger) GetName() string
- func (f XFieldInteger) GetType() int
- func (f XFieldInteger) IsAutoIncrement() bool
- type XFieldSet
- type XFieldText
- func (f XFieldText) CreateField(prepend string, DB string, ifText *bool) string
- func (f XFieldText) CreateIndex(table string, id string, DB string) []string
- func (f XFieldText) CreateSequence(table string) string
- func (f XFieldText) CreateValue(v interface{}, table string, DB string, id string) string
- func (f XFieldText) GetConstraints() XConstraints
- func (f XFieldText) GetName() string
- func (f XFieldText) GetType() int
- type XFieldVarChar
- func (f XFieldVarChar) CreateField(prepend string, DB string, ifText *bool) string
- func (f XFieldVarChar) CreateIndex(table string, id string, DB string) []string
- func (f XFieldVarChar) CreateSequence(table string) string
- func (f XFieldVarChar) CreateValue(v interface{}, table string, DB string, id string) string
- func (f XFieldVarChar) GetConstraints() XConstraints
- func (f XFieldVarChar) GetName() string
- func (f XFieldVarChar) GetType() int
- type XGroup
- type XGroupBy
- type XHaving
- type XOrder
- type XOrderBy
- type XRecord
- func (r *XRecord) Clone() xcore.XDatasetDef
- func (r *XRecord) Del(key string)
- func (r *XRecord) Get(key string) (interface{}, bool)
- func (r *XRecord) GetBool(key string) (bool, bool)
- func (r *XRecord) GetBoolCollection(key string) ([]bool, bool)
- func (r *XRecord) GetCollection(key string) (xcore.XDatasetCollectionDef, bool)
- func (r *XRecord) GetDataset(key string) (xcore.XDatasetDef, bool)
- func (r *XRecord) GetFloat(key string) (float64, bool)
- func (r *XRecord) GetFloatCollection(key string) ([]float64, bool)
- func (r *XRecord) GetInt(key string) (int, bool)
- func (r *XRecord) GetIntCollection(key string) ([]int, bool)
- func (r *XRecord) GetString(key string) (string, bool)
- func (r *XRecord) GetStringCollection(key string) ([]string, bool)
- func (r *XRecord) GetTime(key string) (time.Time, bool)
- func (r *XRecord) GetTimeCollection(key string) ([]time.Time, bool)
- func (r *XRecord) GoString() string
- func (r *XRecord) Set(key string, data interface{})
- func (r *XRecord) String() string
- type XRecordDef
- type XRecords
- func (r *XRecords) Clone() xcore.XDatasetCollectionDef
- func (r *XRecords) Count() int
- func (r *XRecords) Get(index int) (xcore.XDatasetDef, bool)
- func (r *XRecords) GetCollection(key string) (xcore.XDatasetCollectionDef, bool)
- func (r *XRecords) GetData(key string) (interface{}, bool)
- func (d *XRecords) GetDataBool(key string) (bool, bool)
- func (d *XRecords) GetDataFloat(key string) (float64, bool)
- func (d *XRecords) GetDataInt(key string) (int, bool)
- func (r *XRecords) GetDataString(key string) (string, bool)
- func (d *XRecords) GetDataTime(key string) (time.Time, bool)
- func (r *XRecords) GoString() string
- func (r *XRecords) Pop() xcore.XDatasetDef
- func (r *XRecords) Push(data xcore.XDatasetDef)
- func (d *XRecords) Shift() xcore.XDatasetDef
- func (r *XRecords) String() string
- func (d *XRecords) Unshift(data xcore.XDatasetDef)
- type XRecordsDef
- type XTable
- func (t *XTable) AddField(field XFieldDef)
- func (t *XTable) Avg(field string, args ...interface{}) (interface{}, error)
- func (t *XTable) Count(args ...interface{}) (int, error)
- func (t *XTable) Delete(args ...interface{}) (int, error)
- func (t *XTable) GetField(name string) XFieldDef
- func (t *XTable) GetPrimaryKey() XFieldDef
- func (t *XTable) Insert(data interface{}, args ...interface{}) (interface{}, error)
- func (t *XTable) Max(field string, args ...interface{}) (interface{}, error)
- func (t *XTable) Min(field string, args ...interface{}) (interface{}, error)
- func (t *XTable) Select(args ...interface{}) (interface{}, error)
- func (t *XTable) SelectAll(args ...interface{}) (*XRecords, error)
- func (t *XTable) SelectOne(args ...interface{}) (*XRecord, error)
- func (t *XTable) SetBase(base *XBase)
- func (t *XTable) SetLanguage(lang language.Tag)
- func (t *XTable) Synchronize(args ...interface{}) error
- func (t *XTable) Update(args ...interface{}) (int, error)
- func (t *XTable) Upsert(args ...interface{}) (int, error)
- type XTransaction
Examples ¶
Constants ¶
const ( // Version of XDominion VERSION = "0.4.2" // The distinct supported databases DB_Postgres = "postgres" DB_MySQL = "mysql" DB_Localhost = "localhost" )
const ( OP_Equal = "=" OP_NotEqual = "!=" OP_Inferior = "<=" OP_StrictInferior = "<" OP_Superior = ">=" OP_StrictSuperior = ">" OP_Between = "between" OP_In = "in" OP_NotIn = "not in" OP_Like = "like" OP_NotLike = "not like" OP_iLike = "ilike" OP_NotiLike = "not ilike" )
const ( PK = "pk" NN = "nn" AI = "ai" FK = "fk" IN = "in" UI = "ui" MI = "mi" MU = "mu" DC = "dc" TR = "tr" )
const ( XField_Int = 1 XField_VarChar = 2 XField_Float = 3 XField_DateTime = 4 XField_Date = 5 XField_Text = 6 )
const ( ASC = "asc" DESC = "desc" )
Variables ¶
var DEBUG bool = false
Functions ¶
func IsAutoIncrement ¶
func IsFieldConstraint ¶
func IsPrimaryKey ¶
returns true if the field is a primary key for the table
Types ¶
type XBase ¶
type XBase struct { DB *sql.DB Logged bool DBType string Username string Password string Database string Host string SSL bool Logger *log.Logger }
Example ¶
base := &XBase{ DBType: DB_Postgres, Username: "username", Password: "password", Database: "test", Host: DB_Localhost, SSL: false, } base.Logon()
Output:
func (*XBase) BeginTransaction ¶ added in v0.3.3
func (b *XBase) BeginTransaction() (*XTransaction, error)
type XCondition ¶
type XCondition struct { Field string Operator string Limit interface{} LimitExtra interface{} OperatorGlobal string AtomOpen int AtomClose int }
func NewXCondition ¶
func NewXCondition(field string, operator string, limit interface{}, args ...interface{}) XCondition
func (*XCondition) Clone ¶ added in v0.4.2
func (c *XCondition) Clone() XCondition
func (*XCondition) GetCondition ¶
type XConditions ¶
type XConditions []XCondition
func (*XConditions) Clone ¶ added in v0.4.2
func (c *XConditions) Clone() XConditions
func (*XConditions) CreateConditions ¶
func (c *XConditions) CreateConditions(table *XTable, DB string, baseindex int) (string, []interface{})
type XConstraint ¶
type XConstraints ¶
type XConstraints []XConstraint
func (*XConstraints) CreateConstraints ¶
func (c *XConstraints) CreateConstraints(prepend string, name string, DB string) string
func (*XConstraints) CreateIndex ¶ added in v0.3.3
func (*XConstraints) Get ¶
func (c *XConstraints) Get(ctype string) *XConstraint
type XFieldDate ¶
type XFieldDate struct { Name string Constraints XConstraints }
func (XFieldDate) CreateField ¶
func (f XFieldDate) CreateField(prepend string, DB string, ifText *bool) string
creates the name of the field with its type (to create the table)
func (XFieldDate) CreateIndex ¶
func (f XFieldDate) CreateIndex(table string, id string, DB string) []string
creates the index used by the field (normal, unique, multi, multi unique)
func (XFieldDate) CreateSequence ¶
func (f XFieldDate) CreateSequence(table string) string
creates the sequence used by the field (only autoincrement fields)
func (XFieldDate) CreateValue ¶
func (f XFieldDate) CreateValue(v interface{}, table string, DB string, id string) string
creates a string representation of the value of the field for insert/update and queries where
func (XFieldDate) GetConstraints ¶
func (f XFieldDate) GetConstraints() XConstraints
gets the checks of the field
type XFieldDateTime ¶
type XFieldDateTime struct { Name string Constraints XConstraints }
func (XFieldDateTime) CreateField ¶
func (f XFieldDateTime) CreateField(prepend string, DB string, ifText *bool) string
creates the name of the field with its type (to create the table)
func (XFieldDateTime) CreateIndex ¶
func (f XFieldDateTime) CreateIndex(table string, id string, DB string) []string
creates the index used by the field (normal, unique, multi, multi unique)
func (XFieldDateTime) CreateSequence ¶
func (f XFieldDateTime) CreateSequence(table string) string
creates the sequence used by the field (only autoincrement fields)
func (XFieldDateTime) CreateValue ¶
func (f XFieldDateTime) CreateValue(v interface{}, table string, DB string, id string) string
creates a string representation of the value of the field for insert/update and queries where
func (XFieldDateTime) GetConstraints ¶
func (f XFieldDateTime) GetConstraints() XConstraints
gets the checks of the field
type XFieldDef ¶
type XFieldDef interface { // creates the name of the field with its type (to create the table) CreateField(prepend string, DB string, ifText *bool) string // creates a string representation of the value of the field for insert/update with ' for text CreateValue(v interface{}, table string, DB string, id string) string // creates the sequence used by the field (only autoincrement fields) CreateSequence(table string) string // creates the index used by the field (normal, unique, multi, multi unique) CreateIndex(table string, id string, DB string) []string // gets the name of the field GetName() string // gets the type of the field GetType() int // gets the checks of the field GetConstraints() XConstraints }
type XFieldFloat ¶
type XFieldFloat struct { Name string Constraints XConstraints }
func (XFieldFloat) CreateField ¶
func (f XFieldFloat) CreateField(prepend string, DB string, ifText *bool) string
creates the name of the field with its type (to create the table)
func (XFieldFloat) CreateIndex ¶
func (f XFieldFloat) CreateIndex(table string, id string, DB string) []string
creates the index used by the field (normal, unique, multi, multi unique)
func (XFieldFloat) CreateSequence ¶
func (f XFieldFloat) CreateSequence(table string) string
creates the sequence used by the field (only autoincrement fields)
func (XFieldFloat) CreateValue ¶
func (f XFieldFloat) CreateValue(v interface{}, table string, DB string, id string) string
creates a string representation of the value of the field for insert/update
func (XFieldFloat) GetConstraints ¶
func (f XFieldFloat) GetConstraints() XConstraints
gets the checks of the field
type XFieldInteger ¶
type XFieldInteger struct { Name string Constraints XConstraints }
func (XFieldInteger) CreateField ¶
func (f XFieldInteger) CreateField(prepend string, DB string, ifText *bool) string
creates the name of the field with its type (to create the table)
func (XFieldInteger) CreateIndex ¶
func (f XFieldInteger) CreateIndex(table string, id string, DB string) []string
creates the index used by the field (normal, unique, multi, multi unique)
func (XFieldInteger) CreateSequence ¶
func (f XFieldInteger) CreateSequence(table string) string
creates the sequence used by the field (only autoincrement fields)
func (XFieldInteger) CreateValue ¶
func (f XFieldInteger) CreateValue(v interface{}, table string, DB string, id string) string
creates a string representation of the value of the field for insert/update
func (XFieldInteger) GetConstraints ¶
func (f XFieldInteger) GetConstraints() XConstraints
gets the checks of the field
func (XFieldInteger) IsAutoIncrement ¶
func (f XFieldInteger) IsAutoIncrement() bool
Is it autoincrement
type XFieldText ¶
type XFieldText struct { Name string Constraints XConstraints }
func (XFieldText) CreateField ¶
func (f XFieldText) CreateField(prepend string, DB string, ifText *bool) string
creates the name of the field with its type (to create the table)
func (XFieldText) CreateIndex ¶
func (f XFieldText) CreateIndex(table string, id string, DB string) []string
creates the index used by the field (normal, unique, multi, multi unique)
func (XFieldText) CreateSequence ¶
func (f XFieldText) CreateSequence(table string) string
creates the sequence used by the field (only autoincrement fields)
func (XFieldText) CreateValue ¶
func (f XFieldText) CreateValue(v interface{}, table string, DB string, id string) string
creates a string representation of the value of the field for insert/update and queries where
func (XFieldText) GetConstraints ¶
func (f XFieldText) GetConstraints() XConstraints
gets the checks of the field
type XFieldVarChar ¶
type XFieldVarChar struct { Name string Size int Constraints XConstraints }
func (XFieldVarChar) CreateField ¶
func (f XFieldVarChar) CreateField(prepend string, DB string, ifText *bool) string
creates the name of the field with its type (to create the table)
func (XFieldVarChar) CreateIndex ¶
func (f XFieldVarChar) CreateIndex(table string, id string, DB string) []string
creates the index used by the field (normal, unique, multi, multi unique)
func (XFieldVarChar) CreateSequence ¶
func (f XFieldVarChar) CreateSequence(table string) string
creates the sequence used by the field (only autoincrement fields)
func (XFieldVarChar) CreateValue ¶
func (f XFieldVarChar) CreateValue(v interface{}, table string, DB string, id string) string
creates a string representation of the value of the field for insert/update and queries where
func (XFieldVarChar) GetConstraints ¶
func (f XFieldVarChar) GetConstraints() XConstraints
gets the checks of the field
type XHaving ¶
type XHaving []XCondition
type XOrderBy ¶
func NewXOrderBy ¶
type XRecord ¶
type XRecord map[string]interface{}
func NewXRecord ¶
func NewXRecord() *XRecord
func (*XRecord) GetCollection ¶
func (*XRecord) GetDataset ¶
func (*XRecord) GetFloatCollection ¶
func (*XRecord) GetStringCollection ¶
func (*XRecord) GetTimeCollection ¶
type XRecordDef ¶
type XRecordDef interface { xcore.XDatasetDef }
type XRecordsDef ¶
type XRecordsDef interface { xcore.XDatasetCollectionDef }
type XTable ¶
type XTable struct { Base *XBase Name string Prepend string // content of table language, informative Language language.Tag Fields []XFieldDef InsertedKey interface{} }
func (*XTable) GetPrimaryKey ¶
func (*XTable) Insert ¶
Insert things into database: If data is XRecord, insert the record. Returns the key (same type as field type) interface{} If data is XRecords, insert the collection of XRecord. Returns an array of keys (same type as field type) []interface{} If data is SubQuery, intert the result of the sub query, return ?
func (*XTable) SetLanguage ¶
func (*XTable) Synchronize ¶
type XTransaction ¶ added in v0.3.3
func (*XTransaction) Commit ¶ added in v0.3.3
func (t *XTransaction) Commit() error
func (*XTransaction) Exec ¶ added in v0.3.3
func (t *XTransaction) Exec(query string, args ...interface{}) (*sql.Rows, error)
func (*XTransaction) Rollback ¶ added in v0.3.3
func (t *XTransaction) Rollback() error