Documentation ¶
Index ¶
- Constants
- Variables
- type MySQLConnectionParams
- type MySQLGoDataEntity
- type MySQLGoDataEntitySet
- type MySQLGoDataProvider
- func (builder *MySQLGoDataProvider) BindProperty(a, b *MySQLGoDataEntitySet, apath, atarget, bpath, btarget string)
- func (p *MySQLGoDataProvider) BuildFromClause(r *GoDataRequest) ([]byte, []string, error)
- func (builder *MySQLGoDataProvider) BuildMetadata() *GoDataMetadata
- func (p *MySQLGoDataProvider) BuildQuery(r *GoDataRequest) (string, error)
- func (p *MySQLGoDataProvider) BuildSelectClause(r *GoDataRequest) ([]byte, []string, error)
- func (p *MySQLGoDataProvider) BuildWhereClause(r *GoDataRequest) ([]byte, []string, error)
- func (builder *MySQLGoDataProvider) ExposeEntity(tblname, entityname string) *MySQLGoDataEntity
- func (builder *MySQLGoDataProvider) ExposeEntitySet(entity *MySQLGoDataEntity, setname string) *MySQLGoDataEntitySet
- func (builder *MySQLGoDataProvider) ExposeManyToMany(a, b *MySQLGoDataEntity, tblname, aprop, bprop string)
- func (builder *MySQLGoDataProvider) ExposeManyToOne(a, b *MySQLGoDataEntity, acol, aprop, bprop string)
- func (builder *MySQLGoDataProvider) ExposeOneToOne(a, b *MySQLGoDataEntity, acol, bcol, aprop, bprop string)
- func (p *MySQLGoDataProvider) Response(r *GoDataRequest) *GoDataResponse
Constants ¶
const ( XMLNamespace string = "http://docs.oasis-open.org/odata/ns/edmx" ODataVersion string = "4.0" )
Variables ¶
var MySQLNodeMap = map[string]string{
"eq": "(%s = %s)",
"nq": "(%s != %s)",
"gt": "(%s > %s)",
"ge": "(%s >= %s)",
"lt": "(%s < %s)",
"le": "(%s <= %s)",
"and": "(%s AND %s)",
"or": "(%s OR %s)",
"not": "(NOT %s)",
"contains": "(%s LIKE %s)",
"endswith": "(%s LIKE %s)",
"startswith": "(%s LIKE %s)",
"length": "LENGTH(%s)",
"indexof": "LOCATE(%s)",
"tolower": "LOWER(%s)",
"toupper": "UPPER(%s)",
"trim": "TRIM(%s)",
"concat": "CONCAT(%s,%s)",
"year": "YEAR(%s)",
"month": "MONTH(%s)",
"day": "DAY(%s)",
"hour": "HOUR(%s)",
"minute": "MINUTE(%s)",
"second": "SECOND(%s)",
"fractionalsecond": "MICROSECOND(%s)",
"date": "DATE(%s)",
"time": "TIME(%s)",
"now": "NOW()",
"round": "ROUND(%s)",
"floor": "FLOOR(%s)",
"ceiling": "CEIL(%s)",
"null": "NULL",
}
var MySQLPrepareMap = map[string]string{
"contains": "%?%",
"endswith": "%?",
"startswith": "?%",
}
Functions ¶
This section is empty.
Types ¶
type MySQLConnectionParams ¶
type MySQLConnectionParams struct { Database string Hostname string Port string Username string Password string }
Struct to hold MySQL connection parameters.
type MySQLGoDataEntity ¶
type MySQLGoDataEntity struct { TableName string KeyType string PropColMap map[string]string ColPropMap map[string]string EntityType *GoDataEntityType }
func (*MySQLGoDataEntity) ExposeKey ¶
func (entity *MySQLGoDataEntity) ExposeKey(colname, propname, t string)
Expose a key on an entity returned by MySQLGoDataProvider.ExposeEntity. This is a necessary step for every entity. You must provide a column in the database to map to the property name in the OData entity, and the OData type.
func (*MySQLGoDataEntity) ExposePrimitive ¶
func (entity *MySQLGoDataEntity) ExposePrimitive(colname, propname, t string)
Expose an OData primitive property on an entity. You must provide a corresponding table column in the database.
func (*MySQLGoDataEntity) ExposeProperty ¶
func (entity *MySQLGoDataEntity) ExposeProperty(colname, propname, t string)
Expose an OData property on an entity. You must provide a corresponding table column in the database.
type MySQLGoDataEntitySet ¶
type MySQLGoDataEntitySet struct { Entity *MySQLGoDataEntity EntitySet *GoDataEntitySet }
type MySQLGoDataProvider ¶
type MySQLGoDataProvider struct { ConnectionParams *MySQLConnectionParams Namespace string Entities map[string]*MySQLGoDataEntity EntitySets map[string]*MySQLGoDataEntitySet Actions map[string]*GoDataAction Functions map[string]*GoDataFunction Metadata *GoDataMetadata }
A provider for GoData using a MySQL backend. Reads requests, converts them to MySQL queries, and creates a response object to send back to the client.
func BuildMySQLProvider ¶
func BuildMySQLProvider(cxnParams *MySQLConnectionParams, namespace string) *MySQLGoDataProvider
Build an empty MySQL provider. Provide the connection parameters and the namespace name.
func (*MySQLGoDataProvider) BindProperty ¶
func (builder *MySQLGoDataProvider) BindProperty(a, b *MySQLGoDataEntitySet, apath, atarget, bpath, btarget string)
Adds a NavigationPropertyBinding to two entity sets that are mapped together by a relationship. This SHOULD be done for any entity sets for whom their entities contain a NavigationProperty.
func (*MySQLGoDataProvider) BuildFromClause ¶
func (p *MySQLGoDataProvider) BuildFromClause(r *GoDataRequest) ([]byte, []string, error)
Build the from clause in the query, and also return the values to send to the prepared statement.
func (*MySQLGoDataProvider) BuildMetadata ¶
func (builder *MySQLGoDataProvider) BuildMetadata() *GoDataMetadata
Build the $metadata file from the entities in the builder. It creates a schema with the given namespace name.
func (*MySQLGoDataProvider) BuildQuery ¶
func (p *MySQLGoDataProvider) BuildQuery(r *GoDataRequest) (string, error)
func (*MySQLGoDataProvider) BuildSelectClause ¶
func (p *MySQLGoDataProvider) BuildSelectClause(r *GoDataRequest) ([]byte, []string, error)
Build the select clause to begin the query, and also return the values to send to a prepared statement.
func (*MySQLGoDataProvider) BuildWhereClause ¶
func (p *MySQLGoDataProvider) BuildWhereClause(r *GoDataRequest) ([]byte, []string, error)
Build a where clause that can be appended to an SQL query, and also return the values to send to a prepared statement.
func (*MySQLGoDataProvider) ExposeEntity ¶
func (builder *MySQLGoDataProvider) ExposeEntity(tblname, entityname string) *MySQLGoDataEntity
Expose a table in the MySQL database as an entity with the given name in the OData service.
func (*MySQLGoDataProvider) ExposeEntitySet ¶
func (builder *MySQLGoDataProvider) ExposeEntitySet(entity *MySQLGoDataEntity, setname string) *MySQLGoDataEntitySet
Expose a queryable collection of entities
func (*MySQLGoDataProvider) ExposeManyToMany ¶
func (builder *MySQLGoDataProvider) ExposeManyToMany(a, b *MySQLGoDataEntity, tblname, aprop, bprop string)
Adds the necessary NavigationProperty tags to entities to expose a many-to-many relationship from a (Many) -> b (Many). A third table must be provided that has foreign key mappings to the primary keys in both a & b. Both entities will be given a reference to each other with the given names in aprop & bprop.
func (*MySQLGoDataProvider) ExposeManyToOne ¶
func (builder *MySQLGoDataProvider) ExposeManyToOne(a, b *MySQLGoDataEntity, acol, aprop, bprop string)
Adds the necessary NavigationProperty tags to an entity to expose a many-to-one relationship from a (Many) -> b (One). A column name must be provided for entity a which will map to the key in entity b. A reverse property will be added to entity b to map back to entity a, and does not need an explicit column.
func (*MySQLGoDataProvider) ExposeOneToOne ¶
func (builder *MySQLGoDataProvider) ExposeOneToOne(a, b *MySQLGoDataEntity, acol, bcol, aprop, bprop string)
Adds the necessary NavigationProperty tags to entities to expose a one-to-one relationship from a (One) -> b (One). A column name and corresponding property name must be provided for each entity. The columns must be foreign keys corresponding to the primary key in the opposite table.
func (*MySQLGoDataProvider) Response ¶
func (p *MySQLGoDataProvider) Response(r *GoDataRequest) *GoDataResponse
Respond to a GoDataRequest using the MySQL provider.