mysql

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QueryTemplates = map[string]string{
		"GetSingle": "SELECT * " +
			"FROM `{{.TableName}}` AS `_{{.TableName}}`" +
			"{{range .Relations}}" +
			"   LEFT JOIN `{{.Relationship.WithTable}}`" +
			"   ON `{{.Relationship.WithTable}}`.`{{.Relationship.ForeignTableUniqueIDColumn}}`" +
			"   = `_{{$.TableName}}`.`{{.Relationship.LocalTableUniqueIDColumn}}`" +
			"{{end}}" +
			" WHERE `_{{$.TableName}}`.`{{.UniqueIDColumn}}` = ?",
		"GetSingleAsOption": "SELECT `{{.UniqueIDColumn}}`, `{{.ColumnAsOptionName}}` " +
			"FROM `{{.TableName}}` " +
			"WHERE `{{.UniqueIDColumn}}` = ?",
		"GetCollection": "SELECT * " +
			"FROM `{{.TableName}}`",
		"GetCollectionFilterable": "SELECT * " +
			"FROM `{{.TableName}}` " +
			"WHERE `{{.FilterOnColumn}}` {{.Operator}} ?",
		"GetCollectionAsOptions": "SELECT `{{.UniqueIDColumn}}`, `{{.ColumnAsOptionName}}` " +
			"FROM `{{.TableName}}`",
		"GetCollectionAsOptionsFilterable": "SELECT `{{.UniqueIDColumn}}`, `{{.ColumnAsOptionName}}` " +
			"FROM `{{.TableName}}` " +
			"WHERE `{{.ColumnAsOptionName}}` LIKE ?",
		"GetCollectionAsOptionsWithParams": "SELECT `{{.UniqueIDColumn}}`, `{{.ColumnAsOptionName}}` " +
			"FROM `{{.TableName}}` " +
			"WHERE `{{.ColumnAsOptionName}}` LIKE ? " +
			"{{range $index, $element := .ColumnNames}}" +
			"AND `{{$element}}` = ? " +
			"{{end}}",
		"UpdateSingle": "UPDATE `{{.TableName}}` SET `{{.ColumnNames | head}}`" +
			" = ?{{range .ColumnNames | tail}}, `{{.}}` = ?{{end}} WHERE `{{.UniqueIDColumn}}` = ?",
		"CreateSingle": "INSERT INTO `{{.TableName}}`(`{{.ColumnNames | head}}`" +
			"{{range .ColumnNames | tail}}, `{{.}}`{{end}}) " +
			"VALUES(?{{range .ColumnNames | tail}}, ?{{end}})",
		"DeleteSingle": "DELETE FROM `{{.TableName}}` WHERE `{{.UniqueIDColumn}}` = ?",
		"GetTableSchema": "SELECT * " +
			"FROM `{{.TableName}}` " +
			"LIMIT 1",
		"GetTableWithRelationshipsSchema": "SELECT * FROM `{{.TableName}}` AS `_{{.TableName}}`" +
			"{{range .Relations}}" +
			" LEFT JOIN `{{.Relationship.WithTable}}`" +
			" ON `{{.Relationship.WithTable}}`.`{{.Relationship.ForeignTableUniqueIDColumn}}`" +
			" = `_{{$.TableName}}`.`{{.Relationship.LocalTableUniqueIDColumn}}`{{end}} LIMIT 1",
	}
)

Functions

func New

func New() endpoint.Endpoint

Types

type Mysql

type Mysql struct {
	*sqlBackend.SqlBackend
}

Jump to

Keyboard shortcuts

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