qrypgx

package
v0.0.0-...-86a089b Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package qrypgx provides a query backend using postgresql database using the pgx client package.

Index

Constants

View Source
const (
	KindMulti = 1 << iota
	KindSingle
	KindCount
	KindScalar
	KindJoin
	KindJoined
	KindInline
	KindInlined
	KindJSON
)

Variables

This section is empty.

Functions

func CopyFrom

func CopyFrom(db *pgx.ConnPool, s *dom.Schema, fix *lit.Dict) error

func CreateModel

func CreateModel(tx C, s *dom.Schema, m *dom.Model) error

func CreateProject

func CreateProject(db *pgx.ConnPool, p *dom.Project) error

func DropProject

func DropProject(db *pgx.ConnPool, p *dom.Project) error

func Open

func Open(dsn string, logger pgx.Logger) (*pgx.ConnPool, error)

func WithTx

func WithTx(db DB, f func(C) error) error

Types

type Backend

type Backend struct {
	DB *pgx.ConnPool
	mig.Record
	// contains filtered or unexported fields
}

Backend is a specialized postgresql backend using the pgx package.

func New

func New(db *pgx.ConnPool, proj *dom.Project) *Backend

func (*Backend) Close

func (b *Backend) Close() error

Close satisfies the dataset interface but does not close the underlying connection pool.

func (*Backend) Exec

func (b *Backend) Exec(c *exp.Prog, env exp.Env, doc *qry.Doc) (lit.Lit, error)

func (*Backend) Iter

func (b *Backend) Iter(key string) (mig.Iter, error)

func (*Backend) Keys

func (b *Backend) Keys() []string

type C

type C interface {
	Query(string, ...interface{}) (*pgx.Rows, error)
	QueryRow(string, ...interface{}) *pgx.Row
	Exec(string, ...interface{}) (pgx.CommandTag, error)
	Prepare(string, string) (*pgx.PreparedStatement, error)
	CopyFrom(pgx.Identifier, []string, pgx.CopyFromSource) (int, error)
}

type Column

type Column struct {
	*qry.Task
	Key string
	Job *Job
}

type DB

type DB interface {
	Begin() (*pgx.Tx, error)
}

type Job

type Job struct {
	Kind
	// Task is the primary subject of this job.
	*qry.Task
	Cols   []Column
	Tabs   []*qry.Task
	Alias  map[*qry.Task]string
	Parent *Job
	// Deps is the list of immediate dependency tasks for this job, except the parent.
	Deps []*qry.Task
}

Job augments a task with additional information and collects nested and joined jobs.

func (*Job) DependsOn

func (j *Job) DependsOn(t *qry.Task) bool

type Kind

type Kind uint

func (Kind) IsJoined

func (k Kind) IsJoined() bool

func (Kind) IsMulti

func (k Kind) IsMulti() bool

func (Kind) IsScalar

func (k Kind) IsScalar() bool

func (Kind) IsSingle

func (k Kind) IsSingle() bool

type Plan

type Plan struct {
	*qry.Doc
	Jobs []*Job
}

func Analyse

func Analyse(d *qry.Doc) (*Plan, error)

Analyse populates the dependencies for each task in the query plan or returns an error.

Jump to

Keyboard shortcuts

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