db

package
v1.7.8 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TmFmtWithMS = "2006-01-02 15:04:05.999"
	NullStr     = "NULL"
)
View Source
const (
	ColumnDeletedAt = "deleted_at"
	ColumnId        = "id"
	ColumnName      = "name"
)
View Source
const (
	ExprEqual    = " = ?"
	ExprNotEqual = " != ?"
	ExprGreater  = " > ?"
)
View Source
const (
	Mysql    = "mysql"
	Postgres = "postgres"
	Sqlite   = "sqlite"
)
View Source
const (
	Insert    = "INSERT"
	Select    = "SELECT"
	Update    = "UPDATE"
	Delete    = "DELETE"
	LeftJoin  = "LEFT JOIN"
	RightJoin = "RIGHT JOIN"
	InnerJoin = "INNER JOIN"
	Limit     = `LIMIT %d`
	Offset    = `OFFSET %d`
	Limit1    = `LIMIT 1`
)
View Source
const (
	NotDeleted     = ColumnDeletedAt + " IS " + NullStr
	WithNotDeleted = ` AND ` + NotDeleted
)
View Source
const (
	IdEqual   = ColumnId + ExprEqual
	NameEqual = ColumnName + ExprEqual
)

Variables

This section is empty.

Functions

func ConvertParams

func ConvertParams(v interface{}, escaper string) string

func DeleteSQL added in v1.6.13

func DeleteSQL(tableName, column string) string

func ExistsSQL added in v1.6.13

func ExistsSQL(tableName, column string, withDeletedAt bool) string

func ExistsSQLByFilterExprs added in v1.6.13

func ExistsSQLByFilterExprs(tableName string, filters FilterExprs) string

func ExistsSQLByQuerySQL added in v1.6.13

func ExistsSQLByQuerySQL(qsql string) string

func TableName

func TableName(name string, id uint64) string

Types

type Config

type Config struct {
	Type, Charset, Database, TimeZone string
	Host                              string `flag:"name:db_host;usage:数据库host"`
	User, Password                    string
	TimeFormat                        string
	MaxIdleConns, MaxOpenConns        int
	Port                              int32
}

type FilterExpr added in v1.6.13

type FilterExpr struct {
	Field     string        `json:"field"`
	Operation Operation     `json:"method"`
	Value     []interface{} `json:"value"`
}

type FilterExprs added in v1.6.13

type FilterExprs []FilterExpr

func (FilterExprs) Build added in v1.6.13

func (f FilterExprs) Build() string

func (FilterExprs) BuildSQL added in v1.6.13

func (f FilterExprs) BuildSQL() (string, []interface{})

type Operation

type Operation int
const (
	OperationPlace Operation = iota
	Equal
	NotEqual
	Greater
	Less
	Between
	GreaterOrEqual
	LessOrEqual
	IsNotNull
	IsNull
	In
	NotIn
	LIKE
)

func (Operation) SQL

func (m Operation) SQL() string

func (Operation) String

func (m Operation) String() string

Jump to

Keyboard shortcuts

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