db

package
v0.0.0-...-f2fa0db Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSchema

func CreateSchema(db *gorm.DB, models []interface{}) error

CreateSchema creates database schema for test

func ResetTables

func ResetTables(t *testing.T, db *DB, tables ...string) error

ResetTables truncates all data in the specified tables.

Types

type DB

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

DB represents a DB connection that can be used to run SQL queries.

func Init

func Init(ctx context.Context) (*DB, error)

func NewForTest

func NewForTest(t *testing.T, models []interface{}) *DB

NewForTest returns the database connection for testing purpose.

func (*DB) DB

func (db *DB) DB() *gorm.DB

DB returns the dbx.DB wrapped by this object.

func (*DB) With

func (db *DB) With(ctx context.Context) *gorm.DB

With returns a Builder that can be used to build and execute SQL queries. With will return the transaction if it is found in the given context. Otherwise it will return a DB connection associated with the context.

Jump to

Keyboard shortcuts

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