query

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLimit is the default limit if no limit is set in query options
	DefaultLimit = 10
	// MaxLimit is the max limit for page size
	MaxLimit = 50
	// MaxOffset is the max offset
	MaxOffset = 100000
	// DefaultOrderBy is the default column used to order results
	DefaultOrderBy = "created_at"

	// DefaultOrder is the order of the results
	DefaultOrder = orderASC
)

Variables

View Source
var (
	// ErrNoName is returned when name is not set in query option
	// trying to build query for get/update/delete
	ErrNoName     = errors.New("name not set in options")
	ErrNoNameOrID = errors.New("neither name nor id is set in options")
)

Functions

func Delete

Delete builds query for deleting resource

func FilterLabels

func FilterLabels(q *bun.SelectQuery, opts *commonv3.QueryOptions) (*bun.SelectQuery, error)

FilterLabels adds query filter for labels based on the selector

func Get

Get builds query for getting resource

func GetAccountID

func GetAccountID(opts *commonv3.QueryOptions) (string, error)

GetAccountID returns account ID from QueryOptions

func GetClusterID

func GetClusterID(opts *commonv3.QueryOptions) (string, error)

GetClusterID returns cluster ID from QueryOptions

func GetOrganizationID

func GetOrganizationID(opts *commonv3.QueryOptions) (string, error)

GetOrganizationID returns organization id from QueryOptions

func Paginate

func Paginate(q *bun.SelectQuery, opts *commonv3.QueryOptions) *bun.SelectQuery

func Select

Select builds query for selecting resources

func Update

func Update(uq *bun.UpdateQuery, opts *commonv3.QueryOptions) (*bun.UpdateQuery, error)

Update builds query for updating resource

Types

type Option

type Option func(*commonv3.QueryOptions)

Option is the functional query option signature

func WithDeleted

func WithDeleted() Option

WithDeleted sets deleted in query options

func WithExtended

func WithExtended() Option

WithExtended sets extended in query options

func WithGlobalScope

func WithGlobalScope() Option

WithGlobalScope should be used to query resources in global scope partnerID, orgID, projectID = 0, 0, 0

func WithIgnoreScopeDefault

func WithIgnoreScopeDefault() Option

WithIgnoreScopeDefault ignores default values for scope when building queries

func WithMeta

func WithMeta(o *commonv3.Metadata) Option

WithMeta sets meta in query options

func WithName

func WithName(name string) Option

WithName sets name in query options

func WithOptions

func WithOptions(in *commonv3.QueryOptions) Option

WithOptions copies options to query options

func WithOrganizationID

func WithOrganizationID(organizationID string) Option

WithOrganizationID sets organization id in query options

func WithPartnerID

func WithPartnerID(partnerID string) Option

WithPartnerID sets partner id in query options

func WithProjectID

func WithProjectID(projectID string) Option

WithProjectID sets project id in query options

func WithSelector

func WithSelector(selector string) Option

WithSelector sets selector in query options

type QueryFilters added in v0.1.8

type QueryFilters interface {
	GetType() string
	GetUser() string
	GetClient() string
	GetTimefrom() string
	GetPortal() string
	GetCluster() string
	GetNamespace() string
	GetKind() string
	GetMethod() string
	GetQueryString() string
	GetProjects() []string
}

Jump to

Keyboard shortcuts

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