Documentation ¶
Overview ¶
Package querymanager provides the QueryManager facility which allows database queries to be stored away from code and looked up by ID.
The facility adds a component of type dsquery.QueryManager to the IoC container that other components may use to lookup templated queries by an ID and have those queries populated with supplied parameters.
A full description of this facility and how to configure it can be found at http://granitic.io/1.0/ref/query-manager . Also refer to the GoDoc for the GoDoc for the dsquery package.
Template locations and template formats ¶
The QueryManager manager facility is configured with the QueryManager configuration element. For most applications, only the TemplateLocation might need changing from it's default. The default setting is:
{ "QueryManager":{ "TemplateLocation": "resource/queries" } }
On startup, any files in the the TemplateLocation will be treated as containing query templates. The name of each file is not significant. A typical file might look like:
ID:ARTIST_ID_SELECT SELECT id FROM artist WHERE name = '${artistName}' ID:ARTIST_INSERT INSERT INTO artist ( name ) VALUES ( '${artistName}' ) ID:RECORD_INSERT INSERT INTO record ( cat_ref, name, artist_id ) VALUES ( '${catRef}', '${recordName}', ${artistID} )
This file defines three query templates. A new template is signified by a line starting
ID:QUERY_ID
In this example, an application would use the query ID ARTIST_ID_SELECT to recover the first query.
Parameters ¶
A query template may optionally include parameters. Any string inside a ${} structure is considered a parameter name. In the example above, query ID RECORD_INSERT defines three parameters catRef, recordName, artistID. The query manager can be supplied with a map containing keys that match those parameter names and will populate the template with the values associated with those keys.
Index ¶
Constants ¶
const QueryManagerComponentName = instance.FrameworkPrefix + "QueryManager"
The name of the query manager in the IoC container.
const QueryManagerFacilityName = "QueryManager"
The name of the facility
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QueryManagerFacilityBuilder ¶
type QueryManagerFacilityBuilder struct { }
Creates an instance of dsquery.QueryManager and stores it in the IoC container.
func (*QueryManagerFacilityBuilder) BuildAndRegister ¶
func (qmfb *QueryManagerFacilityBuilder) BuildAndRegister(lm *logging.ComponentLoggerManager, ca *config.ConfigAccessor, cn *ioc.ComponentContainer) error
See FacilityBuilder.BuildAndRegister
func (*QueryManagerFacilityBuilder) DependsOnFacilities ¶
func (qmfb *QueryManagerFacilityBuilder) DependsOnFacilities() []string
See FacilityBuilder.DependsOnFacilities
func (*QueryManagerFacilityBuilder) FacilityName ¶
func (qmfb *QueryManagerFacilityBuilder) FacilityName() string
See FacilityBuilder.FacilityName