Documentation ¶
Overview ¶
Package storage sets up database persistence providers.
Package storage sets up database persistence providers.
Package storage sets up database persistence providers.
Index ¶
- func SetMySQLProvider(r *env.Runtime, s *store.Store)
- func SetPostgreSQLProvider(r *env.Runtime, s *store.Store)
- func SetSQLServerProvider(r *env.Runtime, s *store.Store)
- type MySQLProvider
- func (p MySQLProvider) ConvertTimestamp() (statement string)
- func (p MySQLProvider) DatabaseName() string
- func (p MySQLProvider) DriverName() string
- func (p MySQLProvider) Example() string
- func (p MySQLProvider) IsFalse() string
- func (p MySQLProvider) IsTrue() string
- func (p MySQLProvider) JSONEmpty() string
- func (p MySQLProvider) JSONGetValue(column, attribute string) string
- func (p MySQLProvider) MakeConnectionString() string
- func (p MySQLProvider) Params() map[string]string
- func (p MySQLProvider) QueryDateInterval(days int64) string
- func (p MySQLProvider) QueryGetDatabaseVersion() string
- func (p MySQLProvider) QueryGetDatabaseVersionLegacy() string
- func (p MySQLProvider) QueryMeta() string
- func (p MySQLProvider) QueryRecordVersionUpgrade(version int) string
- func (p MySQLProvider) QueryRecordVersionUpgradeLegacy(version int) string
- func (p MySQLProvider) QueryTableList() string
- func (p MySQLProvider) RowLimit(max int) string
- func (p MySQLProvider) Type() env.StoreType
- func (p MySQLProvider) TypeVariant() env.StoreType
- func (p MySQLProvider) VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
- func (p MySQLProvider) VerfiyVersion(dbVersion string) (bool, string)
- type PostgreSQLProvider
- func (p PostgreSQLProvider) ConvertTimestamp() (statement string)
- func (p PostgreSQLProvider) DatabaseName() string
- func (p PostgreSQLProvider) DriverName() string
- func (p PostgreSQLProvider) Example() string
- func (p PostgreSQLProvider) IsFalse() string
- func (p PostgreSQLProvider) IsTrue() string
- func (p PostgreSQLProvider) JSONEmpty() string
- func (p PostgreSQLProvider) JSONGetValue(column, attribute string) string
- func (p PostgreSQLProvider) MakeConnectionString() string
- func (p PostgreSQLProvider) Params() map[string]string
- func (p PostgreSQLProvider) QueryDateInterval(days int64) string
- func (p PostgreSQLProvider) QueryGetDatabaseVersion() string
- func (p PostgreSQLProvider) QueryGetDatabaseVersionLegacy() string
- func (p PostgreSQLProvider) QueryMeta() string
- func (p PostgreSQLProvider) QueryRecordVersionUpgrade(version int) string
- func (p PostgreSQLProvider) QueryRecordVersionUpgradeLegacy(version int) string
- func (p PostgreSQLProvider) QueryTableList() string
- func (p PostgreSQLProvider) RowLimit(max int) string
- func (p PostgreSQLProvider) Type() env.StoreType
- func (p PostgreSQLProvider) TypeVariant() env.StoreType
- func (p PostgreSQLProvider) VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
- func (p PostgreSQLProvider) VerfiyVersion(dbVersion string) (bool, string)
- type SQLServerProvider
- func (p SQLServerProvider) ConvertTimestamp() (statement string)
- func (p SQLServerProvider) DatabaseName() string
- func (p SQLServerProvider) DriverName() string
- func (p SQLServerProvider) Example() string
- func (p SQLServerProvider) IsFalse() string
- func (p SQLServerProvider) IsTrue() string
- func (p SQLServerProvider) JSONEmpty() string
- func (p SQLServerProvider) JSONGetValue(column, attribute string) string
- func (p SQLServerProvider) MakeConnectionString() string
- func (p SQLServerProvider) Params() map[string]string
- func (p SQLServerProvider) QueryDateInterval(days int64) string
- func (p SQLServerProvider) QueryGetDatabaseVersion() string
- func (p SQLServerProvider) QueryGetDatabaseVersionLegacy() string
- func (p SQLServerProvider) QueryMeta() string
- func (p SQLServerProvider) QueryRecordVersionUpgrade(version int) string
- func (p SQLServerProvider) QueryRecordVersionUpgradeLegacy(version int) string
- func (p SQLServerProvider) QueryTableList() string
- func (p SQLServerProvider) RowLimit(max int) string
- func (p SQLServerProvider) Type() env.StoreType
- func (p SQLServerProvider) TypeVariant() env.StoreType
- func (p SQLServerProvider) VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
- func (p SQLServerProvider) VerfiyVersion(dbVersion string) (bool, string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetMySQLProvider ¶
SetMySQLProvider creates MySQL provider
func SetPostgreSQLProvider ¶
SetPostgreSQLProvider creates PostgreSQL provider
func SetSQLServerProvider ¶
SetSQLServerProvider creates PostgreSQL provider.
Useful links:
Driver for Golang:
https://github.com/denisenkom/go-mssqldb
Docker Linux testing:
https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker?view=sql-server-2017 docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Passw0rd' -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2017-latest
JSON types:
https://docs.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-2017
Supports 2016, 2017 and 2019.
Types ¶
type MySQLProvider ¶
type MySQLProvider struct { // User specified connection string. ConnectionString string // User specified db type (mysql, percona or mariadb). Variant env.StoreType }
MySQLProvider supports MySQL 5.7.x and 8.0.x versions.
func (MySQLProvider) ConvertTimestamp ¶ added in v1.73.1
func (p MySQLProvider) ConvertTimestamp() (statement string)
ConvertTimestamp returns SQL function to correctly convert ISO 8601 format (e.g. '2016-09-08T06:37:23Z') to SQL specific timestamp value (e.g. 2016-09-08 06:37:23). Must use ? for parameter placeholder character as DB layer will convert to database specific parameter placeholder character.
func (MySQLProvider) DatabaseName ¶
func (p MySQLProvider) DatabaseName() string
DatabaseName holds the SQL database name where Documize tables live.
func (MySQLProvider) DriverName ¶
func (p MySQLProvider) DriverName() string
DriverName returns database/sql driver name.
func (MySQLProvider) Example ¶
func (p MySQLProvider) Example() string
Example holds storage provider specific connection string format used in error messages.
func (MySQLProvider) JSONEmpty ¶
func (p MySQLProvider) JSONEmpty() string
JSONEmpty returns empty SQL JSON object. Typically used as 2nd parameter to COALESCE().
func (MySQLProvider) JSONGetValue ¶
func (p MySQLProvider) JSONGetValue(column, attribute string) string
JSONGetValue returns JSON attribute selection syntax. Typically used in SELECT <my_json_field> query.
func (MySQLProvider) MakeConnectionString ¶
func (p MySQLProvider) MakeConnectionString() string
MakeConnectionString returns provider specific DB connection string complete with default parameters.
func (MySQLProvider) Params ¶
func (p MySQLProvider) Params() map[string]string
Params returns connection string parameters that must be present before connecting to DB.
func (MySQLProvider) QueryDateInterval ¶
func (p MySQLProvider) QueryDateInterval(days int64) string
QueryDateInterval returns provider specific interval style date SQL.
func (MySQLProvider) QueryGetDatabaseVersion ¶
func (p MySQLProvider) QueryGetDatabaseVersion() string
QueryGetDatabaseVersion returns the schema version number.
func (MySQLProvider) QueryGetDatabaseVersionLegacy ¶
func (p MySQLProvider) QueryGetDatabaseVersionLegacy() string
QueryGetDatabaseVersionLegacy returns the schema version number before The Great Schema Migration (v25, MySQL).
func (MySQLProvider) QueryMeta ¶
func (p MySQLProvider) QueryMeta() string
QueryMeta is how to extract version number, collatio“n, character set from database provider.
func (MySQLProvider) QueryRecordVersionUpgrade ¶
func (p MySQLProvider) QueryRecordVersionUpgrade(version int) string
QueryRecordVersionUpgrade returns database specific insert statement that records the database version number.
func (MySQLProvider) QueryRecordVersionUpgradeLegacy ¶
func (p MySQLProvider) QueryRecordVersionUpgradeLegacy(version int) string
QueryRecordVersionUpgradeLegacy returns database specific insert statement that records the database version number.
func (MySQLProvider) QueryTableList ¶
func (p MySQLProvider) QueryTableList() string
QueryTableList returns a list tables in Documize database.
func (MySQLProvider) RowLimit ¶
func (p MySQLProvider) RowLimit(max int) string
RowLimit returns SQL for limiting number of rows returned.
func (MySQLProvider) Type ¶
func (p MySQLProvider) Type() env.StoreType
Type returns name of provider
func (MySQLProvider) TypeVariant ¶
func (p MySQLProvider) TypeVariant() env.StoreType
TypeVariant returns databse flavor
func (MySQLProvider) VerfiyCharacterCollation ¶
func (p MySQLProvider) VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
VerfiyCharacterCollation needs to ensure utf8/utf8mb4.
func (MySQLProvider) VerfiyVersion ¶
func (p MySQLProvider) VerfiyVersion(dbVersion string) (bool, string)
VerfiyVersion checks to see if actual database meets minimum version requirements.
type PostgreSQLProvider ¶
type PostgreSQLProvider struct { // User specified connection string. ConnectionString string // Unused for this provider. Variant env.StoreType }
PostgreSQLProvider supports by popular demand.
func (PostgreSQLProvider) ConvertTimestamp ¶ added in v1.73.1
func (p PostgreSQLProvider) ConvertTimestamp() (statement string)
ConvertTimestamp returns SQL function to correctly convert ISO 8601 format (e.g. '2016-09-08T06:37:23Z') to SQL specific timestamp value (e.g. 2016-09-08 06:37:23). Must use ? for parameter placeholder character as DB layer will convert to database specific parameter placeholder character.
func (PostgreSQLProvider) DatabaseName ¶
func (p PostgreSQLProvider) DatabaseName() string
DatabaseName holds the SQL database name where Documize tables live.
func (PostgreSQLProvider) DriverName ¶
func (p PostgreSQLProvider) DriverName() string
DriverName returns database/sql driver name.
func (PostgreSQLProvider) Example ¶
func (p PostgreSQLProvider) Example() string
Example holds storage provider specific connection string format used in error messages.
func (PostgreSQLProvider) IsFalse ¶
func (p PostgreSQLProvider) IsFalse() string
IsFalse returns "false"
func (PostgreSQLProvider) IsTrue ¶
func (p PostgreSQLProvider) IsTrue() string
IsTrue returns "true"
func (PostgreSQLProvider) JSONEmpty ¶
func (p PostgreSQLProvider) JSONEmpty() string
JSONEmpty returns empty SQL JSON object. Typically used as 2nd parameter to COALESCE().
func (PostgreSQLProvider) JSONGetValue ¶
func (p PostgreSQLProvider) JSONGetValue(column, attribute string) string
JSONGetValue returns JSON attribute selection syntax. Typically used in SELECT <my_json_field> query.
func (PostgreSQLProvider) MakeConnectionString ¶
func (p PostgreSQLProvider) MakeConnectionString() string
MakeConnectionString returns provider specific DB connection string complete with default parameters.
func (PostgreSQLProvider) Params ¶
func (p PostgreSQLProvider) Params() map[string]string
Params returns connection string parameters that must be present before connecting to DB.
func (PostgreSQLProvider) QueryDateInterval ¶
func (p PostgreSQLProvider) QueryDateInterval(days int64) string
QueryDateInterval returns provider specific interval style date SQL.
func (PostgreSQLProvider) QueryGetDatabaseVersion ¶
func (p PostgreSQLProvider) QueryGetDatabaseVersion() string
QueryGetDatabaseVersion returns the schema version number.
func (PostgreSQLProvider) QueryGetDatabaseVersionLegacy ¶
func (p PostgreSQLProvider) QueryGetDatabaseVersionLegacy() string
QueryGetDatabaseVersionLegacy returns the schema version number before The Great Schema Migration (v25, MySQL).
func (PostgreSQLProvider) QueryMeta ¶
func (p PostgreSQLProvider) QueryMeta() string
QueryMeta is how to extract version number, collation, character set from database provider.
func (PostgreSQLProvider) QueryRecordVersionUpgrade ¶
func (p PostgreSQLProvider) QueryRecordVersionUpgrade(version int) string
QueryRecordVersionUpgrade returns database specific insert statement that records the database version number.
func (PostgreSQLProvider) QueryRecordVersionUpgradeLegacy ¶
func (p PostgreSQLProvider) QueryRecordVersionUpgradeLegacy(version int) string
QueryRecordVersionUpgradeLegacy returns database specific insert statement that records the database version number.
func (PostgreSQLProvider) QueryTableList ¶
func (p PostgreSQLProvider) QueryTableList() string
QueryTableList returns a list tables in Documize database.
func (PostgreSQLProvider) RowLimit ¶
func (p PostgreSQLProvider) RowLimit(max int) string
RowLimit returns SQL for limiting number of rows returned.
func (PostgreSQLProvider) Type ¶
func (p PostgreSQLProvider) Type() env.StoreType
Type returns name of provider
func (PostgreSQLProvider) TypeVariant ¶
func (p PostgreSQLProvider) TypeVariant() env.StoreType
TypeVariant returns databse flavor
func (PostgreSQLProvider) VerfiyCharacterCollation ¶
func (p PostgreSQLProvider) VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
VerfiyCharacterCollation needs to ensure utf8.
func (PostgreSQLProvider) VerfiyVersion ¶
func (p PostgreSQLProvider) VerfiyVersion(dbVersion string) (bool, string)
VerfiyVersion checks to see if actual database meets minimum version requirements.“
type SQLServerProvider ¶
type SQLServerProvider struct { // User specified connection string. ConnectionString string // Unused for this provider. Variant env.StoreType }
SQLServerProvider supports Microsoft SQl Server.
func (SQLServerProvider) ConvertTimestamp ¶
func (p SQLServerProvider) ConvertTimestamp() (statement string)
ConvertTimestamp returns SQL function to correctly convert ISO 8601 format (e.g. '2016-09-08T06:37:23Z') to SQL specific timestamp value (e.g. 2016-09-08 06:37:23).
We must use ? for parameter placeholder character as DB layer will convert to database specific parameter placeholder character.
func (SQLServerProvider) DatabaseName ¶
func (p SQLServerProvider) DatabaseName() string
DatabaseName holds the SQL database name where Documize tables live.
func (SQLServerProvider) DriverName ¶
func (p SQLServerProvider) DriverName() string
DriverName returns database/sql driver name.
func (SQLServerProvider) Example ¶
func (p SQLServerProvider) Example() string
Example holds storage provider specific connection string format used in error messages.
func (SQLServerProvider) JSONEmpty ¶
func (p SQLServerProvider) JSONEmpty() string
JSONEmpty returns empty SQL JSON object. Typically used as 2nd parameter to COALESCE().
func (SQLServerProvider) JSONGetValue ¶
func (p SQLServerProvider) JSONGetValue(column, attribute string) string
JSONGetValue returns JSON attribute selection syntax. Typically used in SELECT <my_json_field> query.
func (SQLServerProvider) MakeConnectionString ¶
func (p SQLServerProvider) MakeConnectionString() string
MakeConnectionString returns provider specific DB connection string complete with default parameters.
func (SQLServerProvider) Params ¶
func (p SQLServerProvider) Params() map[string]string
Params returns connection string parameters that must be present before connecting to DB.
func (SQLServerProvider) QueryDateInterval ¶
func (p SQLServerProvider) QueryDateInterval(days int64) string
QueryDateInterval returns provider specific interval style date SQL.
func (SQLServerProvider) QueryGetDatabaseVersion ¶
func (p SQLServerProvider) QueryGetDatabaseVersion() string
QueryGetDatabaseVersion returns the schema version number.
func (SQLServerProvider) QueryGetDatabaseVersionLegacy ¶
func (p SQLServerProvider) QueryGetDatabaseVersionLegacy() string
QueryGetDatabaseVersionLegacy returns the schema version number before The Great Schema Migration (v25, MySQL).
func (SQLServerProvider) QueryMeta ¶
func (p SQLServerProvider) QueryMeta() string
QueryMeta is how to extract version number, version related comment, character set and collation from database provider.
func (SQLServerProvider) QueryRecordVersionUpgrade ¶
func (p SQLServerProvider) QueryRecordVersionUpgrade(version int) string
QueryRecordVersionUpgrade returns database specific insert statement that records the database version number.
func (SQLServerProvider) QueryRecordVersionUpgradeLegacy ¶
func (p SQLServerProvider) QueryRecordVersionUpgradeLegacy(version int) string
QueryRecordVersionUpgradeLegacy returns database specific insert statement that records the database version number.
func (SQLServerProvider) QueryTableList ¶
func (p SQLServerProvider) QueryTableList() string
QueryTableList returns a list tables in Documize database.
func (SQLServerProvider) RowLimit ¶
func (p SQLServerProvider) RowLimit(max int) string
RowLimit returns SQL for limiting number of rows returned.
func (SQLServerProvider) Type ¶
func (p SQLServerProvider) Type() env.StoreType
Type returns name of provider
func (SQLServerProvider) TypeVariant ¶
func (p SQLServerProvider) TypeVariant() env.StoreType
TypeVariant returns databse flavor
func (SQLServerProvider) VerfiyCharacterCollation ¶
func (p SQLServerProvider) VerfiyCharacterCollation(charset, collation string) (charOK bool, requirements string)
VerfiyCharacterCollation needs to ensure utf8. https://www.red-gate.com/simple-talk/sql/sql-development/questions-sql-server-collations-shy-ask/
func (SQLServerProvider) VerfiyVersion ¶
func (p SQLServerProvider) VerfiyVersion(dbVersion string) (bool, string)
VerfiyVersion checks to see if actual database meets minimum version requirements.