sqlbuilder

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SELECT = "select"
	CREATE = "create"
	INSERT = "insert"
	UPDATE = "update"
	DELETE = "delete"
	WHERE  = "where"
	FIND   = "find"
)

Standard data manipulation operations

Variables

This section is empty.

Functions

func CoalesceQueryBuilder

func CoalesceQueryBuilder(model reflect.Type) string

CoalesceQueryBuilder will wrap the incoming stmt and query attributes in COALESCE with the default types per each attribute. This will avoid errors when null data is found when using find/where Uses all types and names of attributes from passed in model

func IsPointer

func IsPointer(model any) bool

func PointerAttributes

func PointerAttributes(model reflect.Value) []any

Reflect the attributes from given reflect.Value and passed back slice of pointers to found attributes Generally to be used for destructuring a reflect.Slice type

Types

type Query

type Query struct {
	Err       error
	Query     string
	Args      []any
	TableName string

	Attributes []string
	// contains filtered or unexported fields
}

func QueryBuilder

func QueryBuilder(queryType string, model any, databaseType string) Query

Generates SQL query from given model. All attributes of the model are passed back as arguments to the calling function Name of model is lowercased, then snake cased to adhere to SQL naming conventions. A table is expected to exist with the given model name. Used for Create, Update, and Delete

func (*Query) GetModelID

func (q *Query) GetModelID() any

func (*Query) ModelAttributes

func (q *Query) ModelAttributes() []any

Jump to

Keyboard shortcuts

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