query

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DESC is descending order
	DESC = "DESC"
	// ASC is ascending order
	ASC = "ASC"
)

Variables

This section is empty.

Functions

func AND

func AND(args ...string) string

AND creates an AND condition string from the provided arguments.

func EQ

func EQ(fieldName string, value string) string

EQ creates an equality condition string.

func LIKE

func LIKE(fieldName string, value string) string

LIKE creates a LIKE condition string.

func OR

func OR(args ...string) string

OR creates an OR condition string from the provided arguments.

func ValidOrderType

func ValidOrderType(val string) bool

ValidOrderType checks if the given string is a valid ordering type

Types

type Query

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

func New

func New(q string) *Query

New creates a new Query with the given base SQL query string

func (*Query) Limit

func (q *Query) Limit(val string) *Query

Limit adds a LIMIT clause

func (*Query) Offset

func (q *Query) Offset(val string) *Query

Offset adds an OFFSET clause

func (*Query) Order

func (q *Query) Order(by string, orderType string) *Query

Order adds an ORDER BY clause

func (*Query) String

func (q *Query) String() string

String returns the full SQL query string

func (*Query) Where

func (q *Query) Where() *Where

Where returns the WHERE clause for adding conditions

type Where

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

func (*Where) AND

func (w *Where) AND(args ...string) *Where

AND adds an AND condition to the WHERE clause.

func (*Where) EQ

func (w *Where) EQ(fieldName string, value string) *Where

EQ adds an equality condition to the WHERE clause.

func (*Where) LIKE

func (w *Where) LIKE(fieldName string, value string) *Where

LIKE adds a LIKE condition to the WHERE clause.

func (*Where) OR

func (w *Where) OR(args ...string) *Where

OR adds an OR condition to the WHERE clause.

Jump to

Keyboard shortcuts

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