simpleSQLDatabase

package
v0.0.0-...-fdc5c16 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColumnNameTag      = "col"
	DefaultValueTag    = "def"
	IgnoreForInsertTag = "ignoreInsert"
)

Variables

This section is empty.

Functions

func ColumnsFromTag

func ColumnsFromTag(table interface{}, forInsert bool, requireFields []string) (columns []string, err error)

func FieldsFromLocalTable

func FieldsFromLocalTable(table interface{}, forInsert bool) (fields []string, err error)

func NewRowsInstance

func NewRowsInstance(base interface{}) (rows interface{})

func SQLRowsToStructureRows

func SQLRowsToStructureRows(sqlRows *sql.Rows, targetRowType interface{}) (rows []interface{}, err error)

func StringDataFromRow

func StringDataFromRow(row interface{}, requiredField []string) (data []interface{})

Types

type BasicRows

type BasicRows struct {
	Rows []interface{}

	Instance IRows
}

func (BasicRows) Count

func (b BasicRows) Count() int

func (BasicRows) Data

func (b BasicRows) Data(requiredField []string) (data []interface{})

func (BasicRows) DataForInsert

func (b BasicRows) DataForInsert() (data []interface{})

type BasicTable

type BasicTable struct {
	Instance interface{}
	// contains filtered or unexported fields
}

func (BasicTable) Columns

func (b BasicTable) Columns() (list []string)

func (BasicTable) ColumnsForInsert

func (b BasicTable) ColumnsForInsert() (list []string)

func (BasicTable) FieldForInsert

func (b BasicTable) FieldForInsert() (fields []string)

func (BasicTable) FieldsToColumns

func (b BasicTable) FieldsToColumns(fields []string) []string

func (BasicTable) Name

func (b BasicTable) Name() string

type IDriver

type IDriver interface {
	Insert(rows IRows, ignoreKey bool) (result sql.Result, err error)
	Replace(rows IRows) (result sql.Result, err error)
	Update(rows IRows, fields []string, condition string, args []interface{}) (result sql.Result, err error)
	Query(rowType interface{}, sql string, args []interface{}) (rows []interface{}, err error)
	SimpleSelect(rowType interface{}, table string, col string, equalVal interface{}) (rows []interface{}, err error)
	RowCount(table string, condition string, args []interface{}) (cnt uint64, err error)
	SimplePagingQuery(param SimplePagingQueryParam) (ret *SimplePagingQueryResult, err error)
}

type IRows

type IRows interface {
	Table() ITable
	Count() int
	DataForInsert() []interface{}
	Data(requiredColumns []string) []interface{}
}

type ITable

type ITable interface {
	Name() string
	Columns() []string
	ColumnsForInsert() []string
	FieldForInsert() []string
	FieldsToColumns([]string) []string
	NewRows() interface{}
}

type SimplePagingQueryParam

type SimplePagingQueryParam struct {
	Page          int64
	Count         int64
	Table         string
	RowType       interface{}
	Condition     string
	ConditionArgs []interface{}
}

func (*SimplePagingQueryParam) PageFromString

func (s *SimplePagingQueryParam) PageFromString(page string)

type SimplePagingQueryResult

type SimplePagingQueryResult struct {
	Total uint64
	Rows  interface{}
}

Jump to

Keyboard shortcuts

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