query

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFields

func GetFields(fields string) []string

GetFields returns a list of fields for partial response after trimming spaces and making these unique.

func IsValidFields

func IsValidFields(fields []string, partial string) bool

IsValidFields checks if a list of fields for partial response is valid. The fields parameter is a list of valid fields. The partial parameter is a string with the fields to validate. The function returns true if the fields are valid, false otherwise.

Example: IsValidFields(

[]string{"id", "first_name", "last_name", "email", "created_at", "updated_at"},
"id, first_name, last_name"

)

func IsValidFilter

func IsValidFilter(columns []string, filter string) bool

IsValidFilter checks if a filter string is valid SQL syntax. The columns parameter is a list of valid column names. The filter parameter is a string with the filter to validate. The function returns true if the filter is valid, false otherwise.

Example: IsValidFilter(

[]string{"id", "first_name", "last_name", "email", "created_at", "updated_at"},
"id=1 AND first_name='Alice'"

)

func IsValidSort

func IsValidSort(columns []string, sort string) bool

IsValidSort checks if a sort string is valid SQL syntax. The columns parameter is a list of valid column names. The sort parameter is a string with the sort to validate. The function returns true if the sort is valid, false otherwise.

Example: IsValidSort(

[]string{"id", "first_name", "last_name", "email", "created_at", "updated_at"},
"id ASC, first_name DESC"

)

func PrefixFilterFields

func PrefixFilterFields(filter string, prefix string) (string, error)

PrefixFilterFields prefixes the fields in the filter with a given prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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