database

package
v0.0.0-...-bd40a71 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: BSD-3-Clause Imports: 12 Imported by: 79

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Columns

func Columns(ctx context.Context, m Model) []string

func Context

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

func DBForContext

func DBForContext(ctx context.Context) *sql.DB

func ForContext

func ForContext(ctx context.Context) (*sql.Conn, error)

func Middleware

func Middleware(db *sql.DB) func(http.Handler) http.Handler

func Scan

func Scan(ctx context.Context, m Model) []interface{}

func ScanAll

func ScanAll(m Model) []interface{}

func Select

func Select(ctx context.Context, cols ...interface{}) sq.SelectBuilder

func SelectAll

func SelectAll(m Model) sq.SelectBuilder

func WithAlias

func WithAlias(alias, col string) string

func WithTx

func WithTx(ctx context.Context, opts *sql.TxOptions, fn func(tx *sql.Tx) error) error

Types

type ExtendedModel

type ExtendedModel interface {
	Model
	Select(q sq.SelectBuilder) sq.SelectBuilder
}

type FieldMap

type FieldMap struct {
	SQL string
	GQL string
	Ptr interface{}
}

Provides a mapping between PostgreSQL columns, GQL fields, and Go struct fields for all of the data associated with a model.

type Model

type Model interface {
	Alias() string
	Fields() *ModelFields
	Table() string
}

type ModelFields

type ModelFields struct {
	Fields []*FieldMap
	// contains filtered or unexported fields
}

func (*ModelFields) All

func (mf *ModelFields) All() []*FieldMap

func (*ModelFields) Anonymous

func (mf *ModelFields) Anonymous() []*FieldMap

func (*ModelFields) GQL

func (mf *ModelFields) GQL(name string) ([]*FieldMap, bool)

func (*ModelFields) SQL

func (mf *ModelFields) SQL(name string) ([]*FieldMap, bool)

Jump to

Keyboard shortcuts

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