Documentation
¶
Index ¶
- Variables
- type Clickhouse
- func (ch *Clickhouse) CreateMigrationHistoryTable(ctx context.Context) error
- func (ch *Clickhouse) DropMigrationHistoryTable(ctx context.Context) error
- func (ch *Clickhouse) ExecQuery(ctx context.Context, query string, args ...any) error
- func (ch *Clickhouse) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error
- func (ch *Clickhouse) ExistsMigration(ctx context.Context, version string) (bool, error)
- func (ch *Clickhouse) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)
- func (ch *Clickhouse) InsertMigration(ctx context.Context, version string) error
- func (ch *Clickhouse) Migrations(ctx context.Context, limit int) (entity.Migrations, error)
- func (ch *Clickhouse) MigrationsCount(ctx context.Context) (int, error)
- func (ch *Clickhouse) QueryScalar(ctx context.Context, query string, ptr any) error
- func (ch *Clickhouse) RemoveMigration(ctx context.Context, version string) error
- func (ch *Clickhouse) TableNameWithSchema() string
- type ClickhouseFactory
- type Connection
- type DBError
- type Factory
- type FactoryRegistry
- type MySQL
- func (m *MySQL) CreateMigrationHistoryTable(ctx context.Context) error
- func (m *MySQL) DropMigrationHistoryTable(ctx context.Context) error
- func (m *MySQL) ExecQuery(ctx context.Context, query string, args ...any) error
- func (m *MySQL) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error
- func (m *MySQL) ExistsMigration(ctx context.Context, version string) (bool, error)
- func (m *MySQL) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)
- func (m *MySQL) InsertMigration(ctx context.Context, version string) error
- func (m *MySQL) Migrations(ctx context.Context, limit int) (entity.Migrations, error)
- func (m *MySQL) MigrationsCount(ctx context.Context) (int, error)
- func (m *MySQL) QueryScalar(ctx context.Context, query string, ptr any) error
- func (m *MySQL) RemoveMigration(ctx context.Context, version string) error
- func (m *MySQL) TableNameWithSchema() string
- type MySQLFactory
- type Options
- type Postgres
- func (p *Postgres) CreateMigrationHistoryTable(ctx context.Context) error
- func (p *Postgres) DropMigrationHistoryTable(ctx context.Context) error
- func (p *Postgres) ExecQuery(ctx context.Context, query string, args ...any) error
- func (p *Postgres) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error
- func (p *Postgres) ExistsMigration(ctx context.Context, version string) (bool, error)
- func (p *Postgres) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)
- func (p *Postgres) InsertMigration(ctx context.Context, version string) error
- func (p *Postgres) Migrations(ctx context.Context, limit int) (entity.Migrations, error)
- func (p *Postgres) MigrationsCount(ctx context.Context) (int, error)
- func (p *Postgres) QueryScalar(ctx context.Context, query string, ptr any) error
- func (p *Postgres) RemoveMigration(ctx context.Context, version string) error
- func (p *Postgres) TableNameWithSchema() string
- type PostgresFactory
- type Repository
- type Tarantool
- func (p *Tarantool) CreateMigrationHistoryTable(ctx context.Context) error
- func (p *Tarantool) DropMigrationHistoryTable(ctx context.Context) error
- func (p *Tarantool) ExecQuery(ctx context.Context, query string, args ...any) error
- func (p *Tarantool) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error
- func (p *Tarantool) ExistsMigration(ctx context.Context, version string) (bool, error)
- func (p *Tarantool) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)
- func (p *Tarantool) InsertMigration(ctx context.Context, version string) error
- func (p *Tarantool) Migrations(ctx context.Context, limit int) (entity.Migrations, error)
- func (p *Tarantool) MigrationsCount(ctx context.Context) (int, error)
- func (p *Tarantool) QueryScalar(ctx context.Context, query string, ptr any) error
- func (p *Tarantool) RemoveMigration(ctx context.Context, version string) error
- func (p *Tarantool) TableNameWithSchema() string
- type TarantoolFactory
Constants ¶
This section is empty.
Variables ¶
var (
ErrPtrValueMustBeAPointerAndScalar = errors.New("ptr value must be a pointer and scalar")
)
Functions ¶
This section is empty.
Types ¶
type Clickhouse ¶
type Clickhouse struct {
// contains filtered or unexported fields
}
func NewClickhouse ¶
func NewClickhouse(conn Connection, options *Options) *Clickhouse
func (*Clickhouse) CreateMigrationHistoryTable ¶
func (ch *Clickhouse) CreateMigrationHistoryTable(ctx context.Context) error
CreateMigrationHistoryTable creates a new migration history table.
func (*Clickhouse) DropMigrationHistoryTable ¶
func (ch *Clickhouse) DropMigrationHistoryTable(ctx context.Context) error
DropMigrationHistoryTable drops the migration history table.
func (*Clickhouse) ExecQuery ¶
ExecQuery executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*Clickhouse) ExecQueryTransaction ¶
func (ch *Clickhouse) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error
ExecQueryTransaction executes txFn in transaction. todo: называется ExecQuery но query не принимает. подумать
func (*Clickhouse) ExistsMigration ¶ added in v0.4.0
func (*Clickhouse) HasMigrationHistoryTable ¶
func (ch *Clickhouse) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)
HasMigrationHistoryTable returns true if migration history table exists.
func (*Clickhouse) InsertMigration ¶
func (ch *Clickhouse) InsertMigration(ctx context.Context, version string) error
InsertMigration inserts the new migration record.
func (*Clickhouse) Migrations ¶
func (ch *Clickhouse) Migrations(ctx context.Context, limit int) (entity.Migrations, error)
Migrations returns applied migrations history.
func (*Clickhouse) MigrationsCount ¶
func (ch *Clickhouse) MigrationsCount(ctx context.Context) (int, error)
MigrationsCount returns the number of migrations
func (*Clickhouse) QueryScalar ¶ added in v1.2.0
func (*Clickhouse) RemoveMigration ¶
func (ch *Clickhouse) RemoveMigration(ctx context.Context, version string) error
RemoveMigration removes the migration record.
func (*Clickhouse) TableNameWithSchema ¶
func (ch *Clickhouse) TableNameWithSchema() string
type ClickhouseFactory ¶ added in v1.2.0
type ClickhouseFactory struct{}
func (*ClickhouseFactory) Create ¶ added in v1.2.0
func (f *ClickhouseFactory) Create(conn Connection, options *Options) (Repository, error)
func (*ClickhouseFactory) Supports ¶ added in v1.2.0
func (f *ClickhouseFactory) Supports(driver connection.Driver) bool
type Connection ¶
type Connection interface {
io.Closer
DSN() string
Driver() connection.Driver
Ping() error
QueryContext(ctx context.Context, query string, args ...any) (sqlex.Rows, error)
ExecContext(ctx context.Context, query string, args ...any) (sqlex.Result, error)
Transaction(ctx context.Context, txFn func(ctx context.Context) error) error
}
type DBError ¶
type Factory ¶ added in v1.2.0
type Factory interface {
Create(conn Connection, options *Options) (Repository, error)
Supports(driver connection.Driver) bool
}
type FactoryRegistry ¶ added in v1.2.0
type FactoryRegistry struct {
// contains filtered or unexported fields
}
func NewFactoryRegistry ¶ added in v1.2.0
func NewFactoryRegistry() *FactoryRegistry
func (*FactoryRegistry) Create ¶ added in v1.2.0
func (r *FactoryRegistry) Create(conn Connection, options *Options) (Repository, error)
type MySQL ¶
type MySQL struct {
// contains filtered or unexported fields
}
func NewMySQL ¶
func NewMySQL(conn Connection, options *Options) *MySQL
func (*MySQL) CreateMigrationHistoryTable ¶
CreateMigrationHistoryTable creates a new migration history table.
func (*MySQL) DropMigrationHistoryTable ¶
DropMigrationHistoryTable drops the migration history table.
func (*MySQL) ExecQuery ¶
ExecQuery executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*MySQL) ExecQueryTransaction ¶
func (m *MySQL) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error
ExecQueryTransaction executes a query in transaction without returning any rows. The args are for any placeholder parameters in the query.
func (*MySQL) ExistsMigration ¶ added in v0.4.0
func (*MySQL) HasMigrationHistoryTable ¶
HasMigrationHistoryTable returns true if migration history table exists.
func (*MySQL) InsertMigration ¶
InsertMigration inserts the new migration record.
func (*MySQL) Migrations ¶
Migrations returns applied migrations history.
func (*MySQL) MigrationsCount ¶
MigrationsCount returns the number of migrations
func (*MySQL) QueryScalar ¶ added in v1.2.0
func (*MySQL) RemoveMigration ¶
RemoveMigration removes the migration record.
func (*MySQL) TableNameWithSchema ¶
type MySQLFactory ¶ added in v1.2.0
type MySQLFactory struct{}
func (*MySQLFactory) Create ¶ added in v1.2.0
func (f *MySQLFactory) Create(conn Connection, options *Options) (Repository, error)
func (*MySQLFactory) Supports ¶ added in v1.2.0
func (f *MySQLFactory) Supports(driver connection.Driver) bool
type Postgres ¶
type Postgres struct {
// contains filtered or unexported fields
}
func NewPostgres ¶
func NewPostgres(conn Connection, options *Options) *Postgres
func (*Postgres) CreateMigrationHistoryTable ¶
CreateMigrationHistoryTable creates a new migration history table.
func (*Postgres) DropMigrationHistoryTable ¶
DropMigrationHistoryTable drops the migration history table.
func (*Postgres) ExecQuery ¶
ExecQuery executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*Postgres) ExecQueryTransaction ¶
func (p *Postgres) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error
ExecQueryTransaction executes a query in transaction without returning any rows. The args are for any placeholder parameters in the query.
func (*Postgres) ExistsMigration ¶ added in v0.4.0
func (*Postgres) HasMigrationHistoryTable ¶
HasMigrationHistoryTable returns true if migration history table exists.
func (*Postgres) InsertMigration ¶
InsertMigration inserts the new migration record.
func (*Postgres) Migrations ¶
Migrations returns applied migrations history.
func (*Postgres) MigrationsCount ¶
MigrationsCount returns the number of migrations
func (*Postgres) QueryScalar ¶ added in v1.2.0
func (*Postgres) RemoveMigration ¶
RemoveMigration removes the migration record.
func (*Postgres) TableNameWithSchema ¶
type PostgresFactory ¶ added in v1.2.0
type PostgresFactory struct{}
func (*PostgresFactory) Create ¶ added in v1.2.0
func (f *PostgresFactory) Create(conn Connection, options *Options) (Repository, error)
func (*PostgresFactory) Supports ¶ added in v1.2.0
func (f *PostgresFactory) Supports(driver connection.Driver) bool
type Repository ¶
type Repository interface {
Migrations(ctx context.Context, limit int) (entity.Migrations, error)
HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)
InsertMigration(ctx context.Context, version string) error
RemoveMigration(ctx context.Context, version string) error
ExecQuery(ctx context.Context, query string, args ...any) error
QueryScalar(ctx context.Context, query string, ptr any) error
ExecQueryTransaction(ctx context.Context, fnTx func(ctx context.Context) error) error
DropMigrationHistoryTable(ctx context.Context) error
CreateMigrationHistoryTable(ctx context.Context) error
MigrationsCount(ctx context.Context) (int, error)
ExistsMigration(ctx context.Context, version string) (bool, error)
TableNameWithSchema() string
}
func New ¶
func New(conn Connection, options *Options) (Repository, error)
New creates repository by connection
type Tarantool ¶ added in v1.2.0
type Tarantool struct {
// contains filtered or unexported fields
}
func NewTarantool ¶ added in v1.2.0
func NewTarantool(conn Connection, options *Options) *Tarantool
func (*Tarantool) CreateMigrationHistoryTable ¶ added in v1.2.0
CreateMigrationHistoryTable creates a new migration history table.
func (*Tarantool) DropMigrationHistoryTable ¶ added in v1.2.0
DropMigrationHistoryTable drops the migration history table.
func (*Tarantool) ExecQuery ¶ added in v1.2.0
ExecQuery executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*Tarantool) ExecQueryTransaction ¶ added in v1.2.0
func (p *Tarantool) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error
ExecQueryTransaction executes a query in transaction without returning any rows. The args are for any placeholder parameters in the query.
func (*Tarantool) ExistsMigration ¶ added in v1.2.0
func (*Tarantool) HasMigrationHistoryTable ¶ added in v1.2.0
HasMigrationHistoryTable returns true if migration history table exists.
func (*Tarantool) InsertMigration ¶ added in v1.2.0
InsertMigration inserts the new migration record.
func (*Tarantool) Migrations ¶ added in v1.2.0
Migrations returns applied migrations history.
func (*Tarantool) MigrationsCount ¶ added in v1.2.0
MigrationsCount returns the number of migrations
func (*Tarantool) QueryScalar ¶ added in v1.2.0
QueryScalar returns the number of records by query
func (*Tarantool) RemoveMigration ¶ added in v1.2.0
RemoveMigration removes the migration record.
func (*Tarantool) TableNameWithSchema ¶ added in v1.2.0
type TarantoolFactory ¶ added in v1.2.0
type TarantoolFactory struct{}
func (*TarantoolFactory) Create ¶ added in v1.2.0
func (f *TarantoolFactory) Create(conn Connection, options *Options) (Repository, error)
func (*TarantoolFactory) Supports ¶ added in v1.2.0
func (f *TarantoolFactory) Supports(driver connection.Driver) bool