utils

package
v0.0.0-...-41ef176 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DataNotFoundErr  = errors.New("requested data was not found in the database")
	DuplicateDataErr = errors.New("this data already exists")

	DefaultUuid uuid.UUID
)

Functions

func AbortWithRelevantError

func AbortWithRelevantError(err error, c *gin.Context)

func AppendWhereClause

func AppendWhereClause[T any](currentQuery string, columnName string, operand string, value T, isSet func(T) bool, positionalValues []any) (newQuery string, newPositional []any)

func ConvertIfDuplicateErr

func ConvertIfDuplicateErr(err error) error

func ConvertIfNotFoundErr

func ConvertIfNotFoundErr(err error) error

func GetNilIfDefault

func GetNilIfDefault[T comparable](value T) *T

func GetPagesFromItems

func GetPagesFromItems(totalItems int, pageSize int) int

func IsStringNotEmpty

func IsStringNotEmpty(value string) bool

func IsUuidNotEmpty

func IsUuidNotEmpty(value uuid.UUID) bool

func MakeLikeQuery

func MakeLikeQuery(value string) string

func Paginate

func Paginate(completeQuery string, pageIndex int, pageSize int) (query string, countQuery string, err error)

Paginate modifies completeQuery by appending required sql code to it to make pagination happen note that pageIndex is in "user" understandable format, as in it starts with 1

func ParseUuidFromParam

func ParseUuidFromParam(c *gin.Context) (uuid.UUID, error)

func ScanCountQuery

func ScanCountQuery(connector gotabase.Connector, query string, args ...interface{}) (int, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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