Documentation
¶
Index ¶
- Constants
- func ArrayToString(a []string) string
- func SQLDelete(table string, where string) string
- func SQLInsert(table string, columns []string, rows int, placeholder string) string
- func SQLInsertReturning(table string, columns []string, rows int, returning []string, ...) string
- func SQLSelect(columns string, tables string, where string, orderBy string, limit int, ...) string
- func SQLSelectGrouped(columns string, tables string, where string, groupBy string, orderBy string, ...) string
- func SQLSelectSimple(columns string, tables string, where ...string) string
- func SQLUpdate(table string, columns []string, where string, placeholder string) string
- func SQLUpdateReturning(table string, columns []string, where string, returned []string, ...) string
- func StringToArray(s string) []string
- type DBType
- type MySQLParams
- type PostgresParams
- type SQLiteParams
- type Service
- func NewService(typ *DBType, key string, dbName string, schName string, username string, ...) *Service
- func OpenDefaultMySQL(logger *zap.SugaredLogger) (*Service, error)
- func OpenDefaultPostgres(logger *zap.SugaredLogger) (*Service, error)
- func OpenMySQLDatabase(ctx context.Context, key string, params *MySQLParams, ...) (*Service, error)
- func OpenPostgresDatabase(ctx context.Context, key string, params *PostgresParams, ...) (*Service, error)
- func OpenSQLiteDatabase(ctx context.Context, key string, params *SQLiteParams, ...) (*Service, error)
- func (s *Service) Close() error
- func (s *Service) Delete(ctx context.Context, q string, tx *sqlx.Tx, expected int, ...) (int, error)
- func (s *Service) DeleteOne(ctx context.Context, q string, tx *sqlx.Tx, values ...interface{}) error
- func (s *Service) Exec(ctx context.Context, q string, tx *sqlx.Tx, expected int, ...) (int, error)
- func (s *Service) Get(ctx context.Context, dto interface{}, q string, tx *sqlx.Tx, ...) error
- func (s *Service) Insert(ctx context.Context, q string, tx *sqlx.Tx, values ...interface{}) error
- func (s *Service) Query(ctx context.Context, q string, tx *sqlx.Tx, values ...interface{}) (*sqlx.Rows, error)
- func (s *Service) QueryRows(ctx context.Context, q string, tx *sqlx.Tx, values ...interface{}) ([]util.ValueMap, error)
- func (s *Service) QuerySingleRow(ctx context.Context, q string, tx *sqlx.Tx, values ...interface{}) (util.ValueMap, error)
- func (s *Service) Select(ctx context.Context, dest interface{}, q string, tx *sqlx.Tx, ...) error
- func (s *Service) SingleInt(ctx context.Context, q string, tx *sqlx.Tx, values ...interface{}) (int64, error)
- func (s *Service) StartTransaction() (*sqlx.Tx, error)
- func (s *Service) Stats() sql.DBStats
- func (s *Service) Update(ctx context.Context, q string, tx *sqlx.Tx, expected int, ...) (int, error)
- func (s *Service) UpdateOne(ctx context.Context, q string, tx *sqlx.Tx, values ...interface{}) error
Constants ¶
View Source
const SQLiteEnabled = true
Variables ¶
This section is empty.
Functions ¶
func ArrayToString ¶
func SQLInsertReturning ¶
func SQLSelectGrouped ¶
func SQLUpdateReturning ¶
func StringToArray ¶
Types ¶
type MySQLParams ¶
type MySQLParams struct {
Host string `json:"host"`
Port int `json:"port,omitempty"`
Username string `json:"username"`
Password string `json:"password,omitempty"`
Database string `json:"database,omitempty"`
Schema string `json:"schema,omitempty"`
MaxConns int `json:"maxConns,omitempty"`
Debug bool `json:"debug,omitempty"`
}
func MySQLParamsFromEnv ¶
func MySQLParamsFromEnv(key string, defaultUser string, prefix string) *MySQLParams
type PostgresParams ¶
type PostgresParams struct {
Host string `json:"host"`
Port int `json:"port,omitempty"`
Username string `json:"username"`
Password string `json:"password,omitempty"`
Database string `json:"database,omitempty"`
Schema string `json:"schema,omitempty"`
MaxConns int `json:"maxConns,omitempty"`
Debug bool `json:"debug,omitempty"`
}
func PostgresParamsFromEnv ¶
func PostgresParamsFromEnv(key string, defaultUser string, prefix string) *PostgresParams
type SQLiteParams ¶
type SQLiteParams struct {
File string `json:"file"`
Schema string `json:"schema,omitempty"`
Debug bool `json:"debug,omitempty"`
}
func SQLiteParamsFromEnv ¶
func SQLiteParamsFromEnv(key string, defaultUser string, prefix string) *SQLiteParams
type Service ¶
type Service struct {
Key string `json:"key"`
DatabaseName string `json:"database,omitempty"`
SchemaName string `json:"schema,omitempty"`
Username string `json:"username,omitempty"`
Type *DBType `json:"type"`
// contains filtered or unexported fields
}
func NewService ¶
func OpenDefaultMySQL ¶
func OpenDefaultMySQL(logger *zap.SugaredLogger) (*Service, error)
func OpenDefaultPostgres ¶
func OpenDefaultPostgres(logger *zap.SugaredLogger) (*Service, error)
func OpenMySQLDatabase ¶
func OpenMySQLDatabase(ctx context.Context, key string, params *MySQLParams, logger *zap.SugaredLogger) (*Service, error)
func OpenPostgresDatabase ¶
func OpenPostgresDatabase(ctx context.Context, key string, params *PostgresParams, logger *zap.SugaredLogger) (*Service, error)
func OpenSQLiteDatabase ¶
func OpenSQLiteDatabase(ctx context.Context, key string, params *SQLiteParams, logger *zap.SugaredLogger) (*Service, error)
func (*Service) QuerySingleRow ¶
Click to show internal directories.
Click to hide internal directories.