database

package
v0.0.0-...-49d8a14 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: LGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(m Model, input map[string]interface{}) sq.UpdateBuilder

Prepares an UPDATE statement which applies the changes in the input map to the given model.

func Columns

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

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 Select

func Select(ctx context.Context, cols ...interface{}) 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 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