Documentation
¶
Index ¶
- Constants
- func BuildDeleteUri(nid, region, zone, resource string) string
- func BuildInsertUri(nid, region, zone, resource string) string
- func BuildQueryUri(nid, region, zone, resource string) string
- func BuildUpdateUri(nid, region, zone, resource string) string
- func BuildUri(nid, region, zone, nss, resource string) string
- func BuildWhere(values map[string][]string) []runtime.Attr
- type Request
- func NewDeleteRequest(uri, template string, where []runtime.Attr, args ...any) *Request
- func NewInsertRequest(uri, template string, values [][]any, args ...any) *Request
- func NewQueryRequest(uri, template string, where []runtime.Attr, args ...any) *Request
- func NewQueryRequestFromValues(uri, template string, values map[string][]string, args ...any) *Request
- func NewUpdateRequest(uri, template string, attrs []runtime.Attr, where []runtime.Attr, args ...any) *Request
Examples ¶
Constants ¶
View Source
const ( QueryNSS = "query" InsertNSS = "insert" UpdateNSS = "update" DeleteNSS = "delete" PingNSS = "ping" StatNSS = "stat" SelectCmd = 0 InsertCmd = 1 UpdateCmd = 2 DeleteCmd = 3 NullExpectedCount = int64(-1) )
Variables ¶
This section is empty.
Functions ¶
func BuildDeleteUri ¶
BuildDeleteUri - build an uri with the Delete NSS
func BuildInsertUri ¶
BuildInsertUri - build an uri with the Insert NSS
func BuildQueryUri ¶
BuildQueryUri - build an uri with the Query NSS
func BuildUpdateUri ¶
BuildUpdateUri - build an uri with the Update NSS
Types ¶
type Request ¶
type Request struct { ExpectedCount int64 Cmd int Uri string Template string Values [][]any Attrs []runtime.Attr Where []runtime.Attr Args []any Error error }
Request - contains data needed to build the SQL statement related to the uri
func NewDeleteRequest ¶
func NewInsertRequest ¶
func NewQueryRequest ¶
func NewUpdateRequest ¶
func (*Request) Validate ¶
Example ¶
uri := "urn:postgres:query.resource" sql := "select * from table" req := Request{} err := req.Validate() fmt.Printf("test: Validate(empty) -> %v\n", err) req.Uri = uri err = req.Validate() fmt.Printf("test: Validate(%v) -> %v\n", uri, err) req.Uri = "" req.Template = sql err = req.Validate() fmt.Printf("test: Validate(%v) -> %v\n", sql, err) req.Uri = uri req.Template = sql err = req.Validate() fmt.Printf("test: Validate(all) -> %v\n", err) //rsc := "access-log" //t := "delete from access_log" //req1 := NewDeleteRequest(rsc, t, nil) //err = req1.Validate() //fmt.Printf("test: Validate(%v) -> %v\n", t, err) //t = "update access_log" //req1 = NewUpdateRequest(rsc, t, nil, nil) //err = req1.Validate() //fmt.Printf("test: Validate(%v) -> %v\n", t, err) //t = "update access_log" //req1 = NewUpdateRequest(rsc, t, []pgxdml.Attr{{Name: "test", Val: "test"}}, nil) //err = req1.Validate() //fmt.Printf("test: Validate(%v) -> %v\n", t, err)
Output: test: Validate(empty) -> invalid argument: request Uri is empty test: Validate(urn:postgres:query.resource) -> invalid argument: request template is empty test: Validate(select * from table) -> invalid argument: request Uri is empty test: Validate(all) -> <nil>
Click to show internal directories.
Click to hide internal directories.