db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

func NewConnection

func NewConnection(driverName DriverName, dsn string) *Connection

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Connect

func (c *Connection) Connect(ctx context.Context) (*sqlx.DB, error)

func (*Connection) Transact added in v0.2.0

func (c *Connection) Transact(ctx context.Context, fn func(context.Context) error) error

type DataLoader

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

func NewDataLoader

func NewDataLoader(conn *Connection) *DataLoader

func (*DataLoader) Load

func (l *DataLoader) Load(ctx context.Context, table string) (TableData, error)

type DriverName

type DriverName int
const (
	DriverNameUndefined DriverName = iota
	DriverNamePostgres
)

func CreateDriverName

func CreateDriverName(name string) (DriverName, error)

func (DriverName) String

func (n DriverName) String() string

type Inserter added in v0.2.0

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

func NewInserter added in v0.2.0

func NewInserter(db *Connection) *Inserter

func (*Inserter) Insert added in v0.2.0

func (i *Inserter) Insert(ctx context.Context, table string, dataset []map[string]interface{}) (int64, error)

func (*Inserter) Upsert added in v0.2.0

func (i *Inserter) Upsert(ctx context.Context, table *schema.Table, dataset []map[string]interface{}) (int64, error)

type PGLoader

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

func NewPGLoader

func NewPGLoader(conn *Connection) *PGLoader

func (*PGLoader) Load

func (l *PGLoader) Load(ctx context.Context) (*schema.Schema, error)

type SchemaLoader

type SchemaLoader interface {
	// Load database schema
	Load(ctx context.Context) (*schema.Schema, error)
}

func CreateSchemaLoader

func CreateSchemaLoader(conn *Connection) (SchemaLoader, error)

type TableData

type TableData []map[string]interface{}

type Transactioner added in v0.2.0

type Transactioner func(context.Context, func(ctx context.Context) error) error

Jump to

Keyboard shortcuts

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