sql

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const CountTpl = `
SELECT
    COUNT(*)
FROM
    {{ .table_name }}
WHERE
    {{ range .queries }} {{ . }} AND {{ end }} 1 = 1
`
View Source
const DeleteTpl = `
DELETE FROM
    {{ .table_name }}
WHERE
    {{ range .queries }} {{ . }} AND {{ end }} 1 = 1
`
View Source
const InsertTpl = `` /* 289-byte string literal not displayed */
View Source
const QueryTpl = `` /* 318-byte string literal not displayed */
View Source
const UpdateTpl = `
UPDATE
    {{ .table_name }}
SET
    {{ .set_list | join ", " }}
WHERE
    {{ range .queries }} {{ . }} AND {{ end }} 1 = 1
`

Variables

This section is empty.

Functions

func ParseSqlResult

func ParseSqlResult(input any, output any) error

func ParseSqlResultWithColumn added in v0.10.11

func ParseSqlResultWithColumn(input any, output any, columnName string) error

Types

type CheckExistExecuteParams

type CheckExistExecuteParams struct {
	TableName string
	*Conditions
	Values []any
}

func (CheckExistExecuteParams) Map

func (params CheckExistExecuteParams) Map() (map[string]any, error)

type CheckHasOnlyOneExecuteParams

type CheckHasOnlyOneExecuteParams struct {
	TableName string
	*Conditions
}

func (CheckHasOnlyOneExecuteParams) Map

func (params CheckHasOnlyOneExecuteParams) Map() (map[string]any, error)

type Conditions

type Conditions struct {
	// contains filtered or unexported fields
}

func NewConditions

func NewConditions() *Conditions

func (*Conditions) AddCondition

func (conditions *Conditions) AddCondition(query string, values ...any) *Conditions

func (*Conditions) Args added in v0.11.0

func (conditions *Conditions) Args() []any

func (*Conditions) Equal

func (conditions *Conditions) Equal(columnName string, value any) *Conditions

func (*Conditions) GreaterThan

func (conditions *Conditions) GreaterThan(columnName string, value any) *Conditions

func (*Conditions) GreaterThanAndEqual

func (conditions *Conditions) GreaterThanAndEqual(columnName string, value any) *Conditions

func (*Conditions) In

func (conditions *Conditions) In(columnName string, value any) *Conditions

func (*Conditions) LessThan

func (conditions *Conditions) LessThan(columnName string, value any) *Conditions

func (*Conditions) LessThanAndEqual

func (conditions *Conditions) LessThanAndEqual(columnName string, value any) *Conditions

func (*Conditions) Like

func (conditions *Conditions) Like(columnName string, value string) *Conditions

func (*Conditions) Not

func (conditions *Conditions) Not(columnName string, value any) *Conditions

func (*Conditions) NotIn

func (conditions *Conditions) NotIn(columnName string, value any) *Conditions

func (*Conditions) Queries added in v0.11.0

func (conditions *Conditions) Queries() []string

type CountExecuteParams

type CountExecuteParams struct {
	TableName string
	*Conditions
}

func (CountExecuteParams) Map

func (params CountExecuteParams) Map() (map[string]any, error)

type DeleteExecuteParams

type DeleteExecuteParams struct {
	TableName string
	*Conditions
}

func (DeleteExecuteParams) Map

func (params DeleteExecuteParams) Map() (map[string]any, error)

type InsertBatchExecuteParams

type InsertBatchExecuteParams struct {
	TableName     string
	TableRowBatch []TableRow
}

func (InsertBatchExecuteParams) Map

func (params InsertBatchExecuteParams) Map() (map[string]any, error)

type InsertExecuteParams

type InsertExecuteParams struct {
	TableName string
	*TableRow
}

func (InsertExecuteParams) Map

func (params InsertExecuteParams) Map() (map[string]any, error)

type QueryExecuteParams

type QueryExecuteParams struct {
	TableName     string
	SelectClauses []string
	*Conditions
	OrderBy  string
	PageNo   int
	PageSize int
}

func (QueryExecuteParams) Map

func (params QueryExecuteParams) Map() (map[string]any, error)

type QueryOneExecuteParams

type QueryOneExecuteParams struct {
	TableName     string
	SelectClauses []string
	*Conditions
}

func (QueryOneExecuteParams) Map

func (params QueryOneExecuteParams) Map() (map[string]any, error)

type Result

type Result map[string]any

func (Result) ColumnValueBool

func (result Result) ColumnValueBool(columnName string) bool

func (Result) ColumnValueFloat32

func (result Result) ColumnValueFloat32(columnName string) float32

func (Result) ColumnValueFloat64

func (result Result) ColumnValueFloat64(columnName string) float64

func (Result) ColumnValueInt

func (result Result) ColumnValueInt(columnName string) int

func (Result) ColumnValueInt16

func (result Result) ColumnValueInt16(columnName string) int16

func (Result) ColumnValueInt32

func (result Result) ColumnValueInt32(columnName string) int32

func (Result) ColumnValueInt64

func (result Result) ColumnValueInt64(columnName string) int64

func (Result) ColumnValueInt8

func (result Result) ColumnValueInt8(columnName string) int8

func (Result) ColumnValueString

func (result Result) ColumnValueString(columnName string) string

func (Result) ColumnValueStringAsTime

func (result Result) ColumnValueStringAsTime(columnName string) time.Time

func (Result) ColumnValueUint

func (result Result) ColumnValueUint(columnName string) uint

func (Result) ColumnValueUint16

func (result Result) ColumnValueUint16(columnName string) uint16

func (Result) ColumnValueUint32

func (result Result) ColumnValueUint32(columnName string) uint32

func (Result) ColumnValueUint64

func (result Result) ColumnValueUint64(columnName string) uint64

func (Result) ColumnValueUint8

func (result Result) ColumnValueUint8(columnName string) uint8

type TableRow

type TableRow struct {
	// contains filtered or unexported fields
}

func NewTableRow

func NewTableRow() *TableRow

func (*TableRow) Add

func (tableRow *TableRow) Add(column string, value any) *TableRow

func (*TableRow) Columns added in v0.11.0

func (tableRow *TableRow) Columns() []string

func (*TableRow) Values added in v0.11.0

func (tableRow *TableRow) Values() []any

type UpdateExecuteParams

type UpdateExecuteParams struct {
	TableName string
	*TableRow
	*Conditions
}

func (UpdateExecuteParams) Map

func (params UpdateExecuteParams) Map() (map[string]any, error)

Jump to

Keyboard shortcuts

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