engine

package
Version: v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package engine defines interface of an Engine. The engine would know how to truncate a table

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// Truncate a table
	Truncate(table string) error

	// Close db connection
	Close() error
}

Engine is an interface for db interaction layer

func NewPostgresEngine

func NewPostgresEngine(dsn string) Engine

NewPostgresEngine returns engine for Postgres db

type MockEngine

type MockEngine struct {
	mock.Mock
}

MockEngine is an autogenerated mock type for the Engine type

func (*MockEngine) Close

func (_m *MockEngine) Close() error

Close provides a mock function with given fields:

func (*MockEngine) Truncate

func (_m *MockEngine) Truncate(table string) error

Truncate provides a mock function with given fields: table

type MySQL

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

MySQL dbEngine

func NewMySQLEngine

func NewMySQLEngine(dsn string) *MySQL

NewMySQLEngine returns Mysql engine that knows how to truncate a table

func (*MySQL) Close

func (mysql *MySQL) Close() error

func (*MySQL) Truncate

func (mysql *MySQL) Truncate(table string) error

type NoOp

type NoOp struct{}

func (*NoOp) Close

func (n *NoOp) Close() error

func (*NoOp) Truncate

func (n *NoOp) Truncate(table string) error

type Postgres

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

Postgres dbEngine

func (*Postgres) Close

func (p *Postgres) Close() error

func (*Postgres) Truncate

func (p *Postgres) Truncate(table string) error

type SQLite added in v2.3.0

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

MySQL dbEngine

func NewSqliteEngine added in v2.3.0

func NewSqliteEngine(dbFilePath string) *SQLite

NewSQLiteEngine returns SQLite engine

func (*SQLite) Close added in v2.3.0

func (sqlite *SQLite) Close() error

func (*SQLite) Truncate added in v2.3.0

func (sqlite *SQLite) Truncate(table string) error

SQLite does not have an explicit TRUNCATE TABLE command like other databases. Instead, it has added a TRUNCATE optimizer to the DELETE statement.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL