sql

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFields

func BuildFields(f Fields, s []string) string

func BuildPage

func BuildPage(p Page, i int) string

func BuildPageSize

func BuildPageSize(ps PageSize, i int) string

func BuildQuery

func BuildQuery(q Query, key string) string

func BuildSQL

func BuildSQL(fields, page, pageSize, query string) string

Types

type Fields

type Fields func(s []string) string
var BaseFields Fields = func(s []string) string {
	f := make([]string, 0)
	for _, i := range s {
		n := fmt.Sprintf("\"%s\"", i)
		f = append(f, n)
	}
	k := strings.Join(f, ", ")
	return fmt.Sprintf("\"fields\":[%s]", k)
}

type Page

type Page func(i int) string
var BasePage Page = func(i int) string {
	return fmt.Sprintf("\"page\":%d", i)
}

type PageSize

type PageSize func(i int) string
var BasePageSize PageSize = func(i int) string {
	return fmt.Sprintf("\"page_size\":%d", i)
}

type Query

type Query func(key string) string
var QueryID Query = func(groupID string) string {
	return fmt.Sprintf("\"query\":{\"$and\":[{\"groupId\":{\"$exists\":true}},{\"srvId\":{\"$exists\":true}},{\"groupId\":{\"$eq\":\"%s\"}}]}", groupID)
}
var QueryName Query = func(name string) string {
	return fmt.Sprintf("\"query\":{\"$and\":[{\"groupId\":{\"$exists\":true}},{\"srvId\":{\"$exists\":true}},{\"name\":{\"$eq\":\"%s\"}}]}", name)
}

Jump to

Keyboard shortcuts

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