operations

package
v0.12.3-alpha4 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

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"`
	LogLevel           string `json:"log_level" yaml:"log_level"`
}

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 (op *Operations) ExecuteRawSql(sqlStr string, args ...any) ([]sql.Result, error)

func (*Operations) ExecuteRawSqlTemplate added in v0.11.1

func (op *Operations) ExecuteRawSqlTemplate(sqlStr string, executeParams map[string]any, args ...any) ([]sql.Result, error)

func (*Operations) RollbackTransaction

func (op *Operations) RollbackTransaction()

type Table

type Table struct {
	TableName string
	Columns   []TableColumn
}

func (*Table) ToDBModel

func (spec *Table) ToDBModel() (any, error)

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)

Jump to

Keyboard shortcuts

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