seal

package module
v0.0.0-...-d72f891 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 5 Imported by: 2

README

seal

Simple and Powerful SQL Builder For Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(exps ...expr.Expr) expr.Expr

And generates an AND expression which concatenates the given expressions with "AND".

func Avg

func Avg(col string, alias_table ...string) expr.Expr

Avg generates an AVG() expression

func Between

func Between(col string, from, to interface{}) expr.Expr

Between generates a BETWEEN expression. For example, Between("age", 10, 30) generates: "age" BETWEEN 10 AND 30

func Count

func Count(col string, alias_table ...string) expr.Expr

Count generates a COUNT() expression For example:

Count("id"): 					Count(id)
Count("id","id_count"): 		Count(id) AS id_count
Count("id","id_count","user"): 	Count(user.id) AS id_count

func Eq

func Eq(col string, val interface{}) expr.Expr

Eq generates a Standard equal expression

func Exists

func Exists(exp expr.Expr) expr.Expr

Exists generates an EXISTS expression by prefixing "EXISTS" to the given expression.

func In

func In(col string, values ...interface{}) expr.Expr

In generates an IN expression for the specified column and the list of allowed values. If values is empty, a SQL "0=1" will be generated which represents a false expression.

func Like

func Like(col string, value string) expr.LikeExp

Like generates a LIKE expression for the specified column and the possible strings that the column should be like. If multiple values are present, the column should be like *all* of them. For example, Like("name", "key", "word") will generate a SQL expression: "name" LIKE "%key%" AND "name" LIKE "%word%".

func Max

func Max(col string, alias_table ...string) expr.Expr

Count generates a MAX() expression

func Min

func Min(col string, alias_table ...string) expr.Expr

Min generates a MIN() expression

func Not

func Not(e expr.Expr) expr.Expr

Not generates a NOT expression which prefixes "NOT" to the specified expression.

func NotBetween

func NotBetween(col string, from, to interface{}) expr.Expr

NotBetween generates a NOT BETWEEN expression. For example, NotBetween("age", 10, 30) generates: "age" NOT BETWEEN 10 AND 30

func NotExists

func NotExists(exp expr.Expr) expr.Expr

NotExists generates an EXISTS expression by prefixing "NOT EXISTS" to the given expression.

func NotIn

func NotIn(col string, values ...interface{}) expr.Expr

NotIn generates an NOT IN expression for the specified column and the list of disallowed values. If values is empty, an empty string will be returned indicating a true expression.

func NotLike

func NotLike(col string, value string) expr.LikeExp

NotLike generates a NOT LIKE expression. For example, NotLike("name", "key", "word") will generate a SQL expression: "name" NOT LIKE "%key%" AND "name" NOT LIKE "%word%". Please see Like() for more details.

func Op

func Op(col string, op string, val interface{}) expr.Expr

Op generates a Standard expression eg. >,>=,<,<=,....

func Or

func Or(exps ...expr.Expr) expr.Expr

Or generates an OR expression which concatenates the given expressions with "OR".

func StaticEq

func StaticEq(col1 string, col2 string) expr.Expr

StaticEq generates a static equal expression which without params

func StaticOp

func StaticOp(col1 string, op string, col2 string) expr.Expr

StaticOp generates a Standard expression Which always used for multi table select

func Sum

func Sum(col string, alias_table ...string) expr.Expr

SUM generates a SUM() expression

Types

type DB

type DB struct {
	query.Query
	// contains filtered or unexported fields
}

DB enhances sql.DB by providing a set of DB-agnostic query building methods. DB allows easier query building and population of data into Go variables.

func Open

func Open(driverName string, sourceName string, opts ...options.SealOptionsFunc) (DB, error)

Open opens a database specified by a driver name and data source name (DSN). Note that Open does not check if DSN is specified correctly. It doesn't try to establish a DB connection either. Please refer to sql.Open() for more information.

func OpenWithDB

func OpenWithDB(db *sql.DB, b builder.Builder, opts ...options.SealOptionsFunc) (DB, error)

OpenWithDB Create a new DB instance. Note that Open does not check if DSN is specified correctly. It doesn't try to establish a DB connection either. Please refer to sql.Open() for more information.

func (*DB) Begin

func (db *DB) Begin() (*Tx, error)

Begin starts a transaction.

func (*DB) Close

func (db *DB) Close() error

Close close the db

type Tx

type Tx struct {
	query.Query
	// contains filtered or unexported fields
}

Tx enhances sql.Tx with additional querying methods.

func (*Tx) Commit

func (t *Tx) Commit() error

Commit commits the transaction.

func (*Tx) Rollback

func (t *Tx) Rollback() error

Rollback aborts the transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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