Documentation ¶
Index ¶
- func DestroyOperation(op *Operations) error
- type Config
- type Operations
- func (op *Operations) AutoMigrate(tables ...Table) error
- func (op *Operations) BeginTransaction() *Operations
- func (op *Operations) CommitTransaction()
- func (op *Operations) ExecuteRawSql(sqlStr string, executeParams map[string]any) ([]sql.Result, error)
- func (op *Operations) ExecuteSql(_ string, _ map[string]any) ([]sql.Result, error)
- func (op *Operations) RollbackTransaction()
- type Table
- type TableColumn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DestroyOperation ¶
func DestroyOperation(op *Operations) error
Types ¶
type Config ¶
type Config struct { UserName string `json:"user_name" yaml:"user_name"` Password string `json:"password" yaml:"password"` Address string `json:"address" yaml:"address"` Port string `json:"port" yaml:"port"` Database string `json:"database" yaml:"database"` MaxConnections int `json:"max_connections" yaml:"max_connections"` MaxIdleConnections int `json:"max_idle_connections" yaml:"max_idle_connections"` }
type Operations ¶
type Operations struct {
// contains filtered or unexported fields
}
func NewOperations ¶
func NewOperations(dbConfig *Config) (*Operations, error)
func (*Operations) AutoMigrate ¶
func (op *Operations) AutoMigrate(tables ...Table) error
func (*Operations) BeginTransaction ¶
func (op *Operations) BeginTransaction() *Operations
func (*Operations) CommitTransaction ¶
func (op *Operations) CommitTransaction()
func (*Operations) ExecuteRawSql ¶
func (*Operations) ExecuteSql ¶
func (*Operations) RollbackTransaction ¶
func (op *Operations) RollbackTransaction()
type Table ¶
type Table struct { TableName string Columns []TableColumn }
type TableColumn ¶
type TableColumn struct { Name string Type string Comment string PrimaryKey bool Size int Unique bool NotNull bool Index bool UniqueIndex string Default any }
func (*TableColumn) ToDBModelField ¶
func (column *TableColumn) ToDBModelField() (*reflect.StructField, error)
Click to show internal directories.
Click to hide internal directories.