Documentation ¶
Index ¶
- Constants
- Variables
- func DataToItem(rows *sql.Rows, source string) et.Item
- func DataToItems(rows *sql.Rows, source string) et.Items
- func IndexColumn(model *Model, name string) int
- func Register(name string, driver func() Driver)
- func RowsToItem(rows *sql.Rows) et.Item
- func RowsToItems(rows *sql.Rows) et.Items
- func SQLDDL(sql string, args ...any) string
- func SQLParse(sql string, args ...any) string
- func SQLQuote(sql string) string
- type COl
- type ColDetail
- type ColFkey
- type ColFormula
- type ColRequired
- type ColRol
- type Column
- func (c *Column) As(l *Linq) string
- func (c *Column) AsModel(l *Linq) string
- func (c *Column) Between(vals ...interface{}) *Lwhere
- func (c *Column) Concat() string
- func (c *Column) Describe() et.Json
- func (c *Column) Eq(val interface{}) *Lwhere
- func (c *Column) In(vals ...interface{}) *Lwhere
- func (c *Column) Less(val interface{}) *Lwhere
- func (c *Column) LessEq(val interface{}) *Lwhere
- func (c *Column) Like(val interface{}) *Lwhere
- func (c *Column) Low() string
- func (c *Column) More(val interface{}) *Lwhere
- func (c *Column) MoreEq(val interface{}) *Lwhere
- func (c *Column) Neg(val interface{}) *Lwhere
- func (c *Column) NotBetween(vals ...interface{}) *Lwhere
- func (c *Column) SetHidden(val bool)
- func (c *Column) SetIndexed(asc bool)
- func (c *Column) SetRelationTo(parent *Model, parentKey []string, _select []string, calculate TpCaculate, ...)
- func (c *Column) SetRequired(val bool, msg string)
- func (c *Column) SetUnique(val bool)
- func (c *Column) Table() string
- func (c *Column) Up() string
- type Connection
- type Constraint
- type DB
- func (d *DB) Close()
- func (d *DB) Command(sql string, args ...any) (et.Item, error)
- func (d *DB) CurrentSerie(tag string) (int, error)
- func (d *DB) Data(source, sql string, args ...any) (et.Items, error)
- func (d *DB) DataOne(source, sql string, args ...any) (et.Item, error)
- func (d *DB) DeleteSerie(tag string) error
- func (d *DB) Describe() et.Json
- func (d *DB) Disconnected() error
- func (d *DB) Exec(sql string, args ...any) error
- func (d *DB) GetMigrateId(old_id, tag string) (string, error)
- func (d *DB) GetModel(model *Model) *Model
- func (d *DB) GetSchema(schema *Schema) *Schema
- func (d *DB) InitModel(model *Model) error
- func (d *DB) Master(params *Connection) error
- func (d *DB) Model(name string) *Model
- func (d *DB) NextCode(tag, format string) (string, error)
- func (d *DB) NextSerie(tag string) (int, error)
- func (d *DB) Query(sql string, args ...any) (et.Items, error)
- func (d *DB) QueryOne(sql string, args ...any) (et.Item, error)
- func (d *DB) Read(params *Connection) error
- func (d *DB) SetSerie(tag string, val int) error
- func (d *DB) Table(schema, name string) *Model
- func (d *DB) UpSertMigrateId(old_id, _id, tag string) error
- type DDL
- type Definition
- type Driver
- type FuncDetail
- type HandlerListend
- type Index
- type Lcolumns
- type Lfrom
- type Lgroup
- type Linq
- func (l *Linq) All() (et.Items, error)
- func (l *Linq) And(where *Lwhere) *Linq
- func (l *Linq) Avg(col *Column, as string) *Linq
- func (l *Linq) Clear() string
- func (l *Linq) Column(col interface{}) *Column
- func (l *Linq) Concat(cols ...interface{}) *Lwhere
- func (l *Linq) Count(col *Column, as string) *Linq
- func (l *Linq) Data(sel ...interface{}) *Linq
- func (l *Linq) Debug() *Linq
- func (l *Linq) Describe() *et.Json
- func (l *Linq) Distinct() *Linq
- func (l *Linq) Exec() (et.Item, error)
- func (l *Linq) F(as string) *Lfrom
- func (l *Linq) Find() (et.Items, error)
- func (l *Linq) First() (et.Item, error)
- func (l *Linq) From(model *Model, as ...string) *Lfrom
- func (l *Linq) GetAtrib(column *Column) *Lselect
- func (l *Linq) GetColumn(column *Column) *Lselect
- func (l *Linq) GetData(model *Model, name string) *Lselect
- func (l *Linq) GetDetail(column *Column) *Lselect
- func (l *Linq) GetRetun(model *Model, name string) *Lselect
- func (l *Linq) GetSelect(model *Model, name string) *Lselect
- func (l *Linq) Go() (et.Item, error)
- func (l *Linq) GroupBy(columns ...*Column) *Linq
- func (l *Linq) Having(where *Lwhere) *Linq
- func (l *Linq) History(val bool) *Linq
- func (l *Linq) Join(t1, t2 *Model, where *Lwhere) *Linq
- func (l *Linq) Last() (et.Item, error)
- func (l *Linq) LeftJoin(t1, t2 *Model, where *Lwhere) *Linq
- func (l *Linq) List(page, rows int) (et.List, error)
- func (l *Linq) Max(col *Column, as string) *Linq
- func (l *Linq) Min(col *Column, as string) *Linq
- func (l *Linq) One() (et.Item, error)
- func (l *Linq) Or(where *Lwhere) *Linq
- func (l *Linq) OrderBy(asc bool, columns ...*Column) *Linq
- func (l *Linq) OrderByDesc(columns ...*Column) *Linq
- func (l *Linq) Page(page, rows int) (et.Items, error)
- func (l *Linq) Query() (et.Items, error)
- func (l *Linq) Returning(sel ...any) *Linq
- func (l *Linq) RightJoin(t1, t2 *Model, where *Lwhere) *Linq
- func (l *Linq) SQL() string
- func (l *Linq) Select(sel ...interface{}) *Linq
- func (l *Linq) Set(values et.Json) *Linq
- func (l *Linq) ShowModel() *Linq
- func (l *Linq) Skip(n int) (et.Items, error)
- func (l *Linq) Sum(col *Column, as string) *Linq
- func (l *Linq) Take(n int) (et.Items, error)
- func (l *Linq) Where(where *Lwhere) *Linq
- type Listener
- type Ljoin
- type Lorder
- type Lselect
- type Lwhere
- func (w *Lwhere) As() string
- func (w *Lwhere) Between(vals ...interface{}) *Lwhere
- func (w *Lwhere) Describe() et.Json
- func (w *Lwhere) Eq(val interface{}) *Lwhere
- func (w *Lwhere) In(vals ...interface{}) *Lwhere
- func (w *Lwhere) Less(val interface{}) *Lwhere
- func (w *Lwhere) LessEq(val interface{}) *Lwhere
- func (w *Lwhere) Like(val interface{}) *Lwhere
- func (w *Lwhere) More(val interface{}) *Lwhere
- func (w *Lwhere) MoreEq(val interface{}) *Lwhere
- func (w *Lwhere) Neg(val interface{}) *Lwhere
- func (w *Lwhere) NotBetween(vals ...interface{}) *Lwhere
- func (w *Lwhere) Quote() string
- func (w *Lwhere) Unquote() string
- func (w *Lwhere) Where() string
- type ModeDatabase
- type Model
- func (m *Model) AddColumn(col *Column)
- func (m *Model) AddForeignKey(foreignKey []string, parentModel *Model, parentKey []string) *Constraint
- func (m *Model) AddIndex(name string, asc bool) *Column
- func (m *Model) AddPrimaryKey(name string) *Column
- func (m *Model) AddRelationTo(col *Column)
- func (m *Model) AddUnique(name string, asc bool) *Column
- func (m *Model) Avg(col *Column, as string) *Linq
- func (m *Model) C(name string) *Column
- func (m *Model) Col(name string) *Column
- func (m *Model) Column(name string) *Column
- func (m *Model) Count(col *Column, as string) *Linq
- func (m *Model) Data(sel ...interface{}) *Linq
- func (m *Model) DefineAtrib(name, description string, typeData TypeData, _default interface{}) *Column
- func (m *Model) DefineColumn(name, description string, typeData TypeData, _default interface{}) *Column
- func (m *Model) DefineDetail(name, description string, _default interface{}, funcDetail FuncDetail) *Column
- func (m *Model) DefineForeignKey(foreignKey []string, parentModel *Model, parentKey []string) *Model
- func (m *Model) DefineFormula(name, formula string) *Column
- func (m *Model) DefineHidden(cols []string) *Model
- func (m *Model) DefineIndex(name []string, asc bool) *Model
- func (m *Model) DefineIntegrity(integrity bool)
- func (m *Model) DefinePrimaryKey(cols []string) *Model
- func (m *Model) DefineRequired(cols []ColRequired) *Model
- func (m *Model) DefineRollup(name string, foreignKey []string, parentModel *Model, parentKey []string, ...) *Column
- func (m *Model) DefineTrigger(event TypeTrigger, trigger Trigger)
- func (m *Model) DefineUnique(name string, asc bool) *Model
- func (m *Model) Delete() *Linq
- func (m *Model) Describe() et.Json
- func (m *Model) Distinct() *Linq
- func (m *Model) GetMigrateId(old_id string) (string, error)
- func (m *Model) Init(db *DB) error
- func (m *Model) Insert(data et.Json) *Linq
- func (m *Model) Kind() string
- func (m *Model) Max(col *Column, as string) *Linq
- func (m *Model) Min(col *Column, as string) *Linq
- func (m *Model) Select(sel ...interface{}) *Linq
- func (m *Model) Sum(col *Column, as string) *Linq
- func (m *Model) UpSertMigrateId(old_id, _id string) error
- func (m *Model) Update(data et.Json) *Linq
- type Relation
- type RelationTo
- type Required
- type Schema
- type TRigger
- type TpCaculate
- type Trigger
- type TypeColumn
- type TypeCommand
- type TypeData
- type TypeDriver
- type TypeJoin
- type TypeQuery
- type TypeShape
- type TypeTrigger
- type TypeVar
- type Validation
- type Value
- type Values
- func (l *Values) Default(col *Column) interface{}
- func (c *Values) Delete() error
- func (c *Values) DeleteCascade() error
- func (l *Values) Describe() et.Json
- func (c *Values) Insert() error
- func (l *Values) IsDifferent(name string) bool
- func (l *Values) New(def interface{}, name string) interface{}
- func (v *Values) News() et.Json
- func (l *Values) Old(def interface{}, name string) interface{}
- func (v *Values) Olds() et.Json
- func (l *Values) Set(col interface{}, value interface{})
- func (c *Values) Update() error
- func (c *Values) UpdateCascade() error
Constants ¶
const ( MSG_DRIVER_NOT_FOUND = "Driver not found" MSG_DRIVER_REQUIRED = "Driver is required" MSG_UPDATE_ONLY_ALLOW = "Update only allow %d items" MSG_DELETE_ONLY_ALLOW = "Delete only allow %d items" MSG_NOT_FOUND_IDT = "Not found idt in the current values" MSG_CONNECTED_REQUIRED = "Connected is required" MSG_COMMAND_REQUIRED = "Command is required" MSG_SQL_REQUIRED = "Sql is required" MSG_QUERY_NOT_COMMAND = "The query is not a command" )
const ( TpShowOriginal = iota TpUniqueValue TpCountAll TpCountValue TpCountUnique TpCountEmpty TpCountNotEmpty TpPercentEmpty TpPercentNotEmpty TpCount TpSum TpAvg TpMax TpMin )
Variables ¶
var ( MaxUpdate = 1000 MaxDelete = 1000 MaxRows = 1000 )
Global variables
Functions ¶
func DataToItem ¶
* * DataItem return a item from a sql rows and source field * @param rows *sql.Rows * @param source string * @return et.Item *
func DataToItems ¶
* * DataItems return a items from a sql rows and source field * @param rows *sql.Rows * @param source string * @return et.Items *
func IndexColumn ¶
IndexColumn return index of column in model
func RowsToItem ¶
* * RowsToItem return a item from a sql rows * @param rows *sql.Rows * @return et.Item *
func RowsToItems ¶
* * RowsToItems return a items from a sql rows * @param rows *sql.Rows * @return et.Items *
func SQLDDL ¶
* * SQLDDL return a sql string with the args * @param sql string * @param args ...any * @return string *
Types ¶
type ColDetail ¶
type ColDetail struct { Name string Description string Default interface{} FuncDetail FuncDetail }
type ColFormula ¶
type ColRequired ¶
type Column ¶
type Column struct { Model *Model Name string Tag string Description string TypeColumn TypeColumn TypeData TypeData Definition et.Json Default interface{} RelationTo *Relation FuncDetail FuncDetail Formula string PrimaryKey bool ForeignKey bool Indexed bool Unique bool Hidden bool IsDataField bool Required *Required Concats []*Lselect }
Column is a struct for columns in a model
func (*Column) Between ¶
* * Between method to use in column * @param ...interface{} * @return *Lwhere *
func (*Column) LessEq ¶
* * LessEq method to use in column * @param ...interface{} * @return *Lwhere *
func (*Column) MoreEq ¶
* * MoreEq method to use in column * @param ...interface{} * @return *Lwhere *
func (*Column) NotBetween ¶
* * NotBetween method to use in column * @param ...interface{} * @return *Lwhere *
func (*Column) SetRelationTo ¶
func (c *Column) SetRelationTo(parent *Model, parentKey []string, _select []string, calculate TpCaculate, limit int)
SetRequiredTo set required column to model
func (*Column) SetRequired ¶
SetRequired set required column
type Connection ¶
type Connection struct { Name string Drive TypeDriver User string Password string Host string Port int Database string App string Mode ModeDatabase }
type Constraint ¶
* * Constraint is a struct for constraint *
func (*Constraint) Describe ¶
func (c *Constraint) Describe() et.Json
* * Describe return a json with the definition of the constraint * @return et.Json *
func (*Constraint) Fkey ¶
func (c *Constraint) Fkey() string
* * Fkey return a valid name of constraint * @return string *
func (*Constraint) Pkey ¶
func (c *Constraint) Pkey() string
* * Pkey return a valid parent key name of constraint * @return string *
func (*Constraint) Table ¶
func (c *Constraint) Table() string
* * Table return a valid parent table name of constraint * @return string *
type DB ¶
type DB struct { Index int Name string Description string DB *sql.DB WS *ws.Hub Driver *Driver Schemes []*Schema Models []*Model // contains filtered or unexported fields }
* * DB struct to define a database *
func Load ¶
func Load(params *Connection) (*DB, error)
* * Load a database * @return *DB * @return error *
func NewDB ¶
* * NewDB create a new database * @param name string * @param description string * @param drive Driver * @return *DB *
func (*DB) Command ¶
* * Command execute a query in the database and return one item * @parms db * @parms sql * @parms args * @return et.Item * @return error *
func (*DB) CurrentSerie ¶
* * CurrentSerie return the current serie * @param tag string * @return int * @return error *
func (*DB) Data ¶
* * Data execute a query * @param sql string * @param args ...any * @return et.Items * @return error *
func (*DB) DataOne ¶
* * DataOne execute a query and return one item * @param sql string * @param args ...any * @return et.Item * @return error *
func (*DB) DeleteSerie ¶
* * DeleteSerie delete the serie * @param tag string * @return error *
func (*DB) Disconnected ¶
* * Disconnected to database * @return error *
func (*DB) Exec ¶
* * Exec execute a query * @param sql string * @param args ...any * @return error *
func (*DB) GetMigrateId ¶
* * GetMigrateId get a migrate id * @param old_id string * @param tag string * @return string * @return error *
func (*DB) Master ¶
func (d *DB) Master(params *Connection) error
* * Master set the database as master * @param params *Connection * @return error *
func (*DB) NextCode ¶
* * NextCode return the next code * @param tag string * @param format string * @return string * @return error *
func (*DB) NextSerie ¶
* * NextSerie return the next serie * @param tag string * @return int * @return error *
func (*DB) Query ¶
* * Query execute a query in the database * @parms db * @parms sql * @parms args * @return et.Items * @return error *
func (*DB) QueryOne ¶
* * QueryOne execute a query in the database and return one item * @parms db * @parms sql * @parms args * @return et.Item * @return error *
func (*DB) Read ¶ added in v0.0.4
func (d *DB) Read(params *Connection) error
* * Read set the database as master * @param params *Connection * @return error *
func (*DB) SetSerie ¶
* * SetSerie set the serie * @param tag string * @param val int * @return error *
func (*DB) Table ¶
* * Table get model by tablename * @param schema string * @param name string * @return *Model *
func (*DB) UpSertMigrateId ¶
* * UpSertMigrateId upsert a migrate id * @param old_id string * @param _id string * @param tag string * @return error *
type Definition ¶
type Definition struct { Schema string Name string Description string Version int Columns []COl Atribs []COl Indexes []string Uniques []string Hidden []string Required []ColRequired PrimaryKey []string ForeignKey []ColFkey Rollup []ColRol Details []ColDetail Formulas []ColFormula Trigger []TRigger }
type Driver ¶
type Driver interface { Type() string Mode() ModeDatabase LoadMode() error Connect(params *Connection) (*DB, error) Master(params *Connection) (*DB, error) // Listen SetListen(channels []string, handler HandlerListend) SetCommand(query string) error SetMutex(id, query string, index int64) error GetCommand(id string) (et.Item, error) SyncCommand() error // DDL (Data Definition Language) DefineSql(model *Model) string MutationSql(model *Model) string // Crud SelectSql(linq *Linq) string CurrentSql(linq *Linq) string InsertSql(linq *Linq) string UpdateSql(linq *Linq) string DeleteSql(linq *Linq) string // DCL (Data Control Language) DCL(command string, params et.Json) (et.Item, error) // Series NextSerie(tag string) (int, error) NextCode(tag, format string) (string, error) SetSerie(tag string, val int) error CurrentSerie(tag string) (int, error) DeleteSerie(tag string) error // Migration IDs UpSertMigrateId(old_id, _id, tag string) error GetMigrateId(old_id, tag string) (string, error) // Models ModelExist(schema, name string) (bool, error) }
type FuncDetail ¶
Details is a function for details
type HandlerListend ¶
type Lcolumns ¶
Define type columns in linq
func NewColumns ¶
func NewColumns() *Lcolumns
* * NewColumns return a new columns * @return *Lcolumns *
type Lfrom ¶
From struct to use in linq
type Linq ¶
type Linq struct { DB *DB Froms []*Lfrom Columns []*Lselect Atribs []*Lselect Selects *Lcolumns Datas *Lcolumns Returns *Lcolumns Details *Lcolumns Wheres []*Lwhere Groups []*Lgroup Havings []*Lwhere Orders []*Lorder Joins []*Ljoin Union []*Linq Limit int Offset int Values *Values TypeQuery TypeQuery Sql string Args []any Result *et.Item // contains filtered or unexported fields }
Linq struct
func (*Linq) Column ¶
* * Column find column in module to linq * @param name string * @return *Column *
func (*Linq) Describe ¶
* * Describe return a json with the definition of the linq * @return et.Json *
func (*Linq) First ¶
* * First is a function to select first data * @return et.Item * @return error *
func (*Linq) List ¶
* * List is a function to select page data and return list * @return et.List * @return error *
func (*Linq) One ¶
* * QueryOne is a function to execute a query and return one item * @return et.Item * @return error *
func (*Linq) OrderByDesc ¶
* * OrderBy * @param columns *
func (*Linq) Query ¶
* * Query is a function to execute a query * @return et.Items * @return error *
func (*Linq) Skip ¶
* * Skip is a function to skip n element data * @return et.Items * @return error *
type Lselect ¶
type Lselect struct { Linq *Linq From *Lfrom Column *Column AS string TpCaculate TpCaculate }
Select struct to use in linq
func (*Lselect) FuncDetail ¶
Details method to use in linq
type Lwhere ¶
type Lwhere struct { Linq *Linq Columns []*Lselect Operator string Value interface{} Connetor string }
* * Lwhere struct to use in linq *
func Concat ¶
func Concat(cols ...interface{}) *Lwhere
* * Concat struct to use in linq * @param []interfase{} * @return *Lwhere *
func Where ¶
* * Where method to use in linq * @param *Column * @param string * @param interface{} * @return *Lwhere *
func (*Lwhere) Between ¶
* * Between method to use in linq * @param ...interface{} * @return *Lwhere *
func (*Lwhere) LessEq ¶
* * LessEq method to use in linq * @param ...interface{} * @return *Lwhere *
func (*Lwhere) MoreEq ¶
* * MoreEq method to use in linq * @param ...interface{} * @return *Lwhere *
func (*Lwhere) NotBetween ¶
* * NotBetween method to use in linq * @param ...interface{} * @return *Lwhere *
type ModeDatabase ¶
type ModeDatabase int
Mode Database
const ( ModeNone ModeDatabase = iota ModeCore ModeMaster ModeRead ModeMocks )
func ToModeDatabase ¶
func ToModeDatabase(val int) ModeDatabase
* * ToModeDatabase convert int to ModeDatabase * @param val int * @return ModeDatabase *
func (ModeDatabase) IsNone ¶
func (m ModeDatabase) IsNone() bool
* * IsNone return if the mode is none * @return bool *
func (ModeDatabase) String ¶
func (m ModeDatabase) String() string
* * String return string of mode database * @return string *
type Model ¶
type Model struct { Schema *Schema DB *DB Name string Tag string Table string Description string Columns []*Column PrimaryKeys []*Column ForeignKey []*Constraint Index []*Index Unique []*Index RelationTo []*Column Details []*Column Hidden []*Column Required []*Column ColumnStatus *Column ColumnSource *Column ColumnCreatedTime *Column ColumnUpdatedTime *Column ColumnCreatedBy *Column ColumnLastEditedTime *Column ColumnLastEditedBy *Column ColumnProject *Column ColumnSerie *Column ColumnUUIndex *Column BeforeInsert []Trigger AfterInsert []Trigger BeforeUpdate []Trigger AfterUpdate []Trigger BeforeDelete []Trigger AfterDelete []Trigger OnListener Listener Integrity bool DDL *DDL Version int }
* * Model is a struct for model *
func MOdel ¶
func MOdel(def *Definition) *Model
func NewModel ¶
* * NewModel create a new model * @param schema *Schema * @param name string * @param description string * @param version int * @return *Model *
func (*Model) AddForeignKey ¶
func (m *Model) AddForeignKey(foreignKey []string, parentModel *Model, parentKey []string) *Constraint
* * AddForeignKey add foreign key column by name to the model * @param foreignKey []string * @param parentModel *Model * @param parentKey []string * @return *Constraint *
func (*Model) AddIndex ¶
* * AddIndex add index column by name to the model * @param name string * @param asc bool * @return *Column *
func (*Model) AddPrimaryKey ¶
* * AddPrimaryKey add primary key column by name to the model * @param name string * @return *Column *
func (*Model) AddRelationTo ¶
* * AddRelationTo add relation to column to the model * @param col *Column *
func (*Model) AddUnique ¶
* * AddUnique add unique column by name to the model * @param name string * @param asc bool * @return *Column *
func (*Model) C ¶
* * C short to find a column in the model * @param name string * @return *Column *
func (*Model) Col ¶
* * Col short to find a column in the model * @param name string * @return *Column *
func (*Model) Column ¶
* * Column add a column to the model * @param name string * @return *Column *
func (*Model) DefineAtrib ¶
func (m *Model) DefineAtrib(name, description string, typeData TypeData, _default interface{}) *Column
*
- Define atrib define a atrib in the model
- @param name string
- @param description string
- @param typeData TypeData
- @param _default interface{}
- @return *Column
*
func (*Model) DefineColumn ¶
func (m *Model) DefineColumn(name, description string, typeData TypeData, _default interface{}) *Column
*
- Define column define a column in the model
- @param name string
- @param description string
- @param typeData TypeData
- @param _default interface{}
- @return *Column
*
func (*Model) DefineDetail ¶
func (m *Model) DefineDetail(name, description string, _default interface{}, funcDetail FuncDetail) *Column
*
- Define detail define a detail in the model
- @param name string
- @param description string
- @param _default interface{}
- @return *Column
*
func (*Model) DefineForeignKey ¶
func (m *Model) DefineForeignKey(foreignKey []string, parentModel *Model, parentKey []string) *Model
*
- Define foreign key in the model
- @param foreignKey []string
- @param parentModel *Model
- @param parentKey []string
- @return *Model
*
func (*Model) DefineFormula ¶
*
- Define formula in the model
- @param name string
- @param formula string
- @return *Column
*
func (*Model) DefineHidden ¶
*
- Define hidden columns in the model
- @param cols []string
- @return *Model
*
func (*Model) DefineIndex ¶
*
- Define index in the model
- @param name []string
- @param asc bool
- @return *Model
*
func (*Model) DefinePrimaryKey ¶
*
- Define primary key in the model
- @param cols []string
- @return *Model
*
func (*Model) DefineRequired ¶
func (m *Model) DefineRequired(cols []ColRequired) *Model
*
- Define required columns in the model
- @param col string
- @param msg string
- @return *Model
*
func (*Model) DefineRollup ¶
func (m *Model) DefineRollup(name string, foreignKey []string, parentModel *Model, parentKey []string, _select []string) *Column
*
- Define rollup in the model
- @param name string
- @param foreignKey []string
- @param parentModel *Model
- @param parentKey []string
- @param _select string
- @return *Column
*
func (*Model) DefineTrigger ¶
func (m *Model) DefineTrigger(event TypeTrigger, trigger Trigger)
*
- Define trigger in the model
- @param event TypeTrigger
- @param trigger Trigger
*
func (*Model) DefineUnique ¶
*
- Define unique in the model
- @param name string
- @param asc bool
- @return *Model
*
func (*Model) Describe ¶
* * Describe return a json with the definition of the model * @return et.Json *
func (*Model) GetMigrateId ¶
* * GetMigrateId get migrate id * @param old_id string * @return string * @return error *
func (*Model) UpSertMigrateId ¶
* * UpSertMigrateId upsert migrate id * @param old_id string * @param _id string * @return error *
type Relation ¶
type Relation struct { ForeignKey []string Parent *Model ParentKey []string Select []string Calculate TpCaculate Limit int }
Relation is a struct for relation between models
type RelationTo ¶
* * RelationTo is a struct for relation to *
func (*RelationTo) Describe ¶
func (r *RelationTo) Describe() et.Json
* * Describe return a json with the definition of the relation to * @return et.Json *
type Schema ¶
Schema struct used to define a schema in a database
func (*Schema) Describe ¶
* * Describe return a json with the schema description * @return et.Json *
type TRigger ¶
type TRigger struct { TypeTrigger TypeTrigger Trigger Trigger }
type TpCaculate ¶
type TpCaculate int
TpCaculate type for calculate
func (TpCaculate) String ¶
func (t TpCaculate) String() string
String return string of type calculate
type Trigger ¶
* * Trigger is a function for trigger * @param model *Model * @param old et.Json * @param new et.Json * @param data et.Json * @return error *
type TypeColumn ¶
type TypeColumn int
Type columns
const ( TpColumn TypeColumn = iota TpAtrib TpDetail TpConcat TpOther )
type TypeCommand ¶
type TypeCommand int
TypeCommand struct to use in linq
const ( Tpnone TypeCommand = iota TpInsert TpUpdate TpDelete )
Values for TypeCommand
type TypeData ¶
type TypeData int
const ( TpKey TypeData = iota TpText TpMemo TpInteger TpNumber TpSelect TpMultiSelect TpStatus TpDate // Date & Time TpPerson TpFile // files & media TpCheckbox TpURL // URL TpEmail // Email TpPhone TpFormula // Formula TpFunction // Function TpRollup // Rollup (Enrollar) with other model TpCreatedTime TpCreatedBy TpLastEditedTime TpLastEditedBy TpProject TpSource TpJson TpArray TpSerie TpCode TpShape TpUUIndex )
type TypeDriver ¶
type TypeDriver int
const ( Postgres TypeDriver = iota Mysql Sqlite Oracle SQLServer )
func StrToDriver ¶
func StrToDriver(s string) TypeDriver
func (TypeDriver) String ¶
func (d TypeDriver) String() string
* * String return the string of the driver * @return string *
type TypeTrigger ¶
type TypeTrigger int
* * TypeTrigger is a enum for trigger type *
const ( BeforeInsert TypeTrigger = iota AfterInsert BeforeUpdate AfterUpdate BeforeDelete AfterDelete )
func (TypeTrigger) String ¶
func (t TypeTrigger) String() string
* * String return string of type trigger * @return string *
type TypeVar ¶
type TypeVar int
type Validation ¶
Validation tipe function
type Values ¶
type Values struct { Linq *Linq Model *Model TypeCommand TypeCommand Data et.Json Values []*Value Change bool History bool IdT string User interface{} Project interface{} }
Command struct to use in linq
func (*Values) Default ¶
* * Default return the default value of the column in command * @param col *Column * @return interface{} *
func (*Values) DeleteCascade ¶
* * DeleteCascade method to use in linq * @return error *
func (*Values) Describe ¶
* * Describe returns a json with the definition of the command * @return et.Json *
func (*Values) IsDifferent ¶
func (*Values) New ¶
* * New return the new value of the column in command * @param def interface{} * @param name string * @return interface{} *
func (*Values) Old ¶
* * Old return the old value of the column in command * @param def interface{} * @param name string * @return interface{} *
func (*Values) Set ¶
func (l *Values) Set(col interface{}, value interface{})
* * Set values to command * @param col interface{} * @param value interface{} *
func (*Values) UpdateCascade ¶
* * UpdateCascade method to use in linq * @return error *