dialect

package
v0.0.0-...-6945674 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MySQL    = "mysql"
	SQLite   = "sqlite3"
	Postgres = "postgres"
)

Dialect names for external usage.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	// ExecQuerier inheritance
	ExecQuerier
	// Dialect returns the dialect name of the driver.
	Dialect() string
	// Tx starts and returns a new transaction.
	// The provided context is used until the transaction is committed or rolled back.
	Tx(context.Context) (Tx, error)
	// Migrate runs the migrations
	Migrate(FileSystem) error
	// Ping sends a ping request
	Ping(context.Context) error
	// Close closes the underlying connection.
	Close() error
}

Driver is the interface that wraps all necessary operations for ent clients.

func Log

func Log(d Driver, logger Logger) Driver

Log gets a driver and an optional logging function, and returns a new debugged-driver that prints all outgoing operations.

type ExecQuerier

type ExecQuerier interface {
	Execer
	Querier
}

ExecQuerier wraps the standard Exec and Query methods.

type Execer

type Execer interface {
	// Exec executes a query that doesn't return rows. For example, in SQL, INSERT or UPDATE.
	// It scans the result into the pointer v. In SQL, you it's usually sql.Result.
	Exec(ctx context.Context, query string, args, v interface{}) error
}

Execer wraps the exec database operations.

type FileSystem

type FileSystem = fs.FS

FileSystem represents a file sytem storage

type Logger

type Logger = log.Logger

Logger represents a logger

type LoggerDriver

type LoggerDriver struct {
	Driver
	// contains filtered or unexported fields
}

LoggerDriver is a driver that logs all driver operations.

func (*LoggerDriver) Exec

func (d *LoggerDriver) Exec(ctx context.Context, query string, args, v interface{}) error

Exec logs its params and calls the underlying driver Exec method.

func (*LoggerDriver) Query

func (d *LoggerDriver) Query(ctx context.Context, query string, args, v interface{}) error

Query logs its params and calls the underlying driver Query method.

func (*LoggerDriver) Tx

func (d *LoggerDriver) Tx(ctx context.Context) (Tx, error)

Tx adds an log-id for the transaction and calls the underlying driver Tx command.

type LoggerTx

type LoggerTx struct {
	Tx // underlying transaction.
	// contains filtered or unexported fields
}

LoggerTx is a transaction implementation that logs all transaction operations.

func (*LoggerTx) Commit

func (d *LoggerTx) Commit() error

Commit logs this step and calls the underlying transaction Commit method.

func (*LoggerTx) Exec

func (d *LoggerTx) Exec(ctx context.Context, query string, args, v interface{}) error

Exec logs its params and calls the underlying transaction Exec method.

func (*LoggerTx) Query

func (d *LoggerTx) Query(ctx context.Context, query string, args, v interface{}) error

Query logs its params and calls the underlying transaction Query method.

func (*LoggerTx) Rollback

func (d *LoggerTx) Rollback() error

Rollback logs this step and calls the underlying transaction Rollback method.

type Querier

type Querier interface {
	// Query executes a query that returns rows, typically a SELECT in SQL.
	// It scans the result into the pointer v. In SQL, you it's usually *sql.Rows.
	Query(ctx context.Context, query string, args, v interface{}) error
}

Querier wraps the query database operations.

type Tx

type Tx interface {
	// ExecQuerier inheritance
	ExecQuerier
	// actual transaction
	driver.Tx
}

Tx wraps the Exec and Query operations in transaction.

func NopTx

func NopTx(d Driver) Tx

NopTx returns a Tx with a no-op Commit / Rollback methods wrapping the provided Driver d.

Directories

Path Synopsis
sql
Package sql provides wrappers around the standard database/sql package to allow the generated code to interact with a statically-typed API.
Package sql provides wrappers around the standard database/sql package to allow the generated code to interact with a statically-typed API.

Jump to

Keyboard shortcuts

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