helpers

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpectedStruct = fmt.Errorf("expected a struct")
)
View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func Create added in v0.8.0

func Create(t reflect.Type) reflect.Value

func Each

func Each(v any, cb func(v reflect.Value, pointer bool) error) error

func EachField

func EachField(v reflect.Value, cb func(sf reflect.StructField, fv reflect.Value) error) error

func FieldName

func FieldName(f reflect.StructField) string

func GetType added in v0.8.0

func GetType[T any]() reflect.Type

func GetValue

func GetValue(v any, key string) (any, bool)

func HasField

func HasField(v any, field string) bool

func Includes

func Includes[T comparable](arr []T, v T) bool

func NewOf added in v0.8.0

func NewOf[T any]() (T, error)

func PrimaryKey

func PrimaryKey(m any) []string

func PrimaryKeyValue added in v0.8.0

func PrimaryKeyValue(m any) ([]any, error)

func RGetValue

func RGetValue(v reflect.Value, key string) (reflect.Value, error)

func Zero added in v0.9.0

func Zero[T any]() T

Types

type PrimaryKeyer

type PrimaryKeyer interface {
	PrimaryKey() []string
}

type SQLResult

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

func Result

func Result() *SQLResult

func (*SQLResult) Add

func (r *SQLResult) Add(sqler SQLStringer) *SQLResult

func (*SQLResult) AddString

func (r *SQLResult) AddString(sql string) *SQLResult

func (*SQLResult) SQLString added in v0.10.0

func (r *SQLResult) SQLString(d dialects.Dialect) (string, []any, error)

type SQLStringFunc added in v0.10.0

type SQLStringFunc func(d dialects.Dialect) (string, []any, error)

func (SQLStringFunc) SQLString added in v0.10.0

func (f SQLStringFunc) SQLString(d dialects.Dialect) (string, []any, error)

type SQLStringer added in v0.10.0

type SQLStringer interface {
	SQLString(d dialects.Dialect) (string, []any, error)
}

func Concat

func Concat(sqlers ...SQLStringer) SQLStringer

func Group

func Group(sqler SQLStringer) SQLStringer

func Identifier

func Identifier(i string) SQLStringer

func IdentifierList

func IdentifierList(strs []string) []SQLStringer

func Join

func Join[T SQLStringer](sqlers []T, sep string) SQLStringer

func Literal

func Literal(v any) SQLStringer

func LiteralList

func LiteralList(values []any) []SQLStringer

func Raw

func Raw(sql string, bindings ...any) SQLStringer

type Tag

type Tag struct {
	Name          string
	Primary       bool
	AutoIncrement bool
	Readonly      bool
	Index         bool
	Unique        bool
	Type          dialects.DataType
}

func DBTag

func DBTag(f reflect.StructField) *Tag

Jump to

Keyboard shortcuts

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