Documentation
¶
Overview ¶
Credits to https://github.com/gchaincl/dotsql
Index ¶
- type Query
- func (q *Query) GetMetadata(key string) (string, bool)
- func (q *Query) HasSection(tag string) bool
- func (q *Query) Prepare(args map[string]interface{}) []interface{}
- func (q *Query) Query() string
- func (q *Query) RawQuery() string
- func (q *Query) Section(tag string) string
- func (q *Query) SectionNames() []string
- func (q *Query) SectionQuery(tag string) *Query
- type QueryStore
- func (s *QueryStore) LoadFromDir(path string) error
- func (qs *QueryStore) LoadFromEmbed(sqlFS embed.FS, path string) error
- func (s *QueryStore) LoadFromFile(fileName string) (err error)
- func (s *QueryStore) MustHaveQuery(name string) *Query
- func (s *QueryStore) Queries() map[string]*Query
- func (s *QueryStore) Query(name string) (*Query, error)
- func (s *QueryStore) QueryNames() []string
- type ScannedQuery
- type Scanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct {
Name string
Path string
Raw string
OrdinalQuery string
Mapping map[string]int
Args []string
NamedArgs []sql.NamedArg
Metadata map[string]string
// contains filtered or unexported fields
}
func (*Query) GetMetadata ¶ added in v1.1.0
GetMetadata retrieves a metadata value by key
func (*Query) HasSection ¶ added in v1.6.0
HasSection reports whether the query contains a non-empty @tag section.
func (*Query) Prepare ¶
Prepare the arguments for the ordinal query. Missing arguments will be returned as nil
func (*Query) SectionNames ¶ added in v1.6.0
SectionNames returns @tag section names in order of appearance.
func (*Query) SectionQuery ¶ added in v1.6.0
SectionQuery returns a parsed Query for a @tag section, with its own Args and OrdinalQuery.
type QueryStore ¶
type QueryStore struct {
// contains filtered or unexported fields
}
func (*QueryStore) LoadFromDir ¶
func (s *QueryStore) LoadFromDir(path string) error
func (*QueryStore) LoadFromEmbed ¶
func (qs *QueryStore) LoadFromEmbed(sqlFS embed.FS, path string) error
func (*QueryStore) LoadFromFile ¶
func (s *QueryStore) LoadFromFile(fileName string) (err error)
LoadFromFile loads query/queries from specified file
func (*QueryStore) MustHaveQuery ¶
func (s *QueryStore) MustHaveQuery(name string) *Query
MustHaveQuery returns query or panics on error
func (*QueryStore) Queries ¶ added in v1.1.0
func (s *QueryStore) Queries() map[string]*Query
Queries returns all queries in the store as a map
func (*QueryStore) Query ¶
func (s *QueryStore) Query(name string) (*Query, error)
Query retrieve query by given name
func (*QueryStore) QueryNames ¶ added in v1.1.0
func (s *QueryStore) QueryNames() []string
QueryNames returns a sorted list of all query names in the store