sqlutil

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Columns added in v0.30.0

func Columns(names ...string) func(*gorm.DB) *gorm.DB

Columns returns a gorm scope that will select the given columns.

func Context added in v0.30.0

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

Context will return a new context with the given DB object.

func Debug added in v0.30.0

func Debug(ctx context.Context) context.Context

Debug will enable debug logging for the given context.

func FromContext added in v0.30.0

func FromContext(ctx context.Context) *gorm.DB

FromContext will return the DB object from the given context.

func QuoteID

func QuoteID(parts ...string) string

func Transaction added in v0.30.0

func Transaction(ctx context.Context, fn func(context.Context, *gorm.DB) error) error

Transaction will run the given function in a transaction handling commit/rollback and sub-transactions.

Types

type BoolArray

type BoolArray []bool

func (*BoolArray) Scan

func (s *BoolArray) Scan(src interface{}) error

func (BoolArray) Value

func (s BoolArray) Value() (driver.Value, error)

type Error

type Error struct {
	Code           string
	Message        string
	Detail         string
	Hint           string
	TableName      string
	ConstraintName string
	Where          string
	ColumnName     string
	Position       int
	// contains filtered or unexported fields
}

Error represents a driver-agnostic SQL error.

func MapError

func MapError(err error) *Error

MapError will return a Error from the given err object or nil otherwise.

func (Error) Error

func (e Error) Error() string

type IntArray

type IntArray []int

func (*IntArray) Scan

func (a *IntArray) Scan(src interface{}) error

func (IntArray) Value

func (a IntArray) Value() (driver.Value, error)

type Listener

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

Listener will listen for NOTIFY commands on a set of channels.

func NewListener

func NewListener(ctx context.Context, logger *log.Logger, db *sql.DB, channels ...string) (*Listener, error)

NewListener will create and initialize a Listener which will automatically reconnect and listen to the provided channels.

func (*Listener) Close

func (l *Listener) Close() error

Close performs a shutdown with a background context.

func (*Listener) Errors

func (l *Listener) Errors() <-chan error

Errors will return a channel that will be fed errors from this listener.

func (*Listener) Notifications

func (l *Listener) Notifications() <-chan *pgconn.Notification

Notifications returns the notification channel for this listener. Nil values will not be returned until the listener is closed.

func (*Listener) Shutdown added in v0.25.0

func (l *Listener) Shutdown(context.Context) error

Shutdown will shut down the listener and returns after all connections have been completed. It is not necessary to call Stop() before Close().

func (*Listener) Start

func (l *Listener) Start()

Start will enable reconnections and messages.

func (*Listener) Stop

func (l *Listener) Stop()

Stop will end all current connections and stop reconnecting.

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not null
}

func (*NullTime) Scan

func (n *NullTime) Scan(src interface{}) error

func (NullTime) Value

func (n NullTime) Value() (driver.Value, error)

type NullUUID added in v0.28.0

type NullUUID struct {
	UUID  uuid.UUID
	Valid bool
}

func (*NullUUID) Scan added in v0.28.0

func (u *NullUUID) Scan(src interface{}) (err error)

func (NullUUID) Value added in v0.28.0

func (u NullUUID) Value() (driver.Value, error)

type NullUUIDArray added in v0.28.0

type NullUUIDArray struct {
	UUIDArray UUIDArray
	Valid     bool
}

func (*NullUUIDArray) Scan added in v0.28.0

func (s *NullUUIDArray) Scan(src interface{}) error

func (NullUUIDArray) Value added in v0.28.0

func (s NullUUIDArray) Value() (driver.Value, error)

type StringArray

type StringArray []string

func (*StringArray) Scan

func (s *StringArray) Scan(src interface{}) error

func (StringArray) Value

func (s StringArray) Value() (driver.Value, error)

type UUIDArray

type UUIDArray []string

func (*UUIDArray) Scan

func (s *UUIDArray) Scan(src interface{}) error

func (UUIDArray) Value

func (s UUIDArray) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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