xsql

package
Version: v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

extends for the sql package. power by <Joshua Conero>(2020)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

need to do. the sql builder

func Table

func Table(table interface{}, alias ...string) *Builder

Table(string/string interface) Table([]string{name, alias})

func (*Builder) Columns

func (c *Builder) Columns(columns ...string) *Builder

func (*Builder) Delete

func (c *Builder) Delete() *Builder

func (*Builder) GetSQL

func (c *Builder) GetSQL() (string, []interface{})

only get SQL where exist sql if not will call SQL builder

func (*Builder) GetTableString

func (c *Builder) GetTableString() string

func (*Builder) GroupBy

func (c *Builder) GroupBy(groupBys ...string) *Builder

call once, than more to reset.

func (*Builder) InnerJoin

func (c *Builder) InnerJoin(table, cond string) *Builder

func (*Builder) Insert

func (c *Builder) Insert(data map[string]interface{}) *Builder

func (*Builder) Join

func (c *Builder) Join(table, cond, vtype string) *Builder

func (*Builder) LeftJoin

func (c *Builder) LeftJoin(table, cond string) *Builder

func (*Builder) Limit

func (c *Builder) Limit(offset int, orRowCount ...int) *Builder

func (*Builder) OrderBy

func (c *Builder) OrderBy(orderBys ...string) *Builder

call once, than more to reset.

func (*Builder) Page

func (c *Builder) Page(page int, orPageSize ...int) *Builder

func (*Builder) ResetBinds

func (c *Builder) ResetBinds() *Builder

func (*Builder) ResetWhere

func (c *Builder) ResetWhere(where string, binds ...interface{}) *Builder

func (*Builder) RightJoin

func (c *Builder) RightJoin(table, cond string) *Builder

func (*Builder) Select

func (c *Builder) Select(columns ...string) *Builder

func (*Builder) ToSQL

func (c *Builder) ToSQL() (string, []interface{})

build SQL every time

func (*Builder) Update

func (c *Builder) Update(data map[string]interface{}) *Builder

func (*Builder) Where

func (c *Builder) Where(where string, binds ...interface{}) *Builder

type Query

type Query struct {
	DB       *sql.DB
	RowCount int //the count query result lines.
}

func NewQuery

func NewQuery(db *sql.DB) *Query

func (*Query) RowsDick

func (c *Query) RowsDick(rows *sql.Rows) ([]map[string]interface{}, error)

reference link: https://blog.csdn.net/weimingjue/article/details/91042649 get the rows dick database map to golang type:

INT    							int64
SMALLINT,TINYINT    			int
DECIMAL    						float64
DATETIME,DATE    				time.Time; <!temp make to string>
VARCHAR,CHAR,TEXT				string

func (*Query) Select

func (c *Query) Select(query string, args ...interface{}) ([]map[string]interface{}, error)

select

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL