client

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package client provides types and utilities used for interacting with a remote database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client defines a database client.

func NewClient

func NewClient(ctx context.Context, config *Config) (*Client, error)

NewClient returns new storage client from the provided parameters.

func (*Client) Close

func (c *Client) Close() error

Close closes the remote database endpoint connection.

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, name string) (*sql.Result, error)

CreateDatabase creates new database with the provided parameters.

func (*Client) DropDatabase

func (c *Client) DropDatabase(ctx context.Context, name string) (*sql.Result, error)

DropDatabase drops database mathing the provided parameters.

func (*Client) Execute

func (c *Client) Execute(ctx context.Context, query string) (sql.Result, error)

Execute executes query on a remote database endpoint.

func (*Client) LastMigration

func (c *Client) LastMigration(ctx context.Context) (*Migration, error)

LastMigration retrieves the last successfully applied migration name.

func (*Client) RegisterMigration

func (c *Client) RegisterMigration(ctx context.Context, migration *Migration) error

RegisterMigration registers migration as applied on a remote PostgreSQL endpoint.

func (*Client) String

func (c *Client) String() string

String implements fmt.Stringer interface.

type Config added in v1.5.0

type Config struct {
	Endpoint string
	Port     int
	Database string
	Username string
	Password string
	SslMode  string
}

Config defines the Client configuration.

type Migration

type Migration struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Path      string    `json:"path"`
	AppliedBy string    `json:"applied_by"`
	Created   time.Time `json:"created"`
}

Migration defines applied database migration.

Jump to

Keyboard shortcuts

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