xsql

package
v1.1.0-ea1 Latest Latest
Warning

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

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

Documentation

Overview

Package xsql 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
}

Builder need to do. the sql builder

func Table

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

Table 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{})

GetSQL 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

GroupBy 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

OrderBy 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{})

ToSQL 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)

RowsDick 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)

Jump to

Keyboard shortcuts

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