pquery

package
v0.0.0-...-6ae7d31 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider interface {
	AuthFilter(ctx context.Context) (map[string]interface{}, error)
}

type AuthProviderFunc

type AuthProviderFunc func(ctx context.Context) (map[string]interface{}, error)

func (AuthProviderFunc) AuthFilter

func (f AuthProviderFunc) AuthFilter(ctx context.Context) (map[string]interface{}, error)

type Column

type Column struct {
	Name string

	// The point within the root element which is stored in the column. An empty
	// path means this stores the root elemet,
	MountPoint *pgstore.Path
}

type GetJoinSpec

type GetJoinSpec struct {
	TableName     string
	DataColumn    string
	On            JoinFields
	FieldInParent protoreflect.Name
}

type GetRequest

type GetRequest interface {
	proto.Message
}

type GetResponse

type GetResponse interface {
	proto.Message
}

type GetSpec

type GetSpec[
	REQ GetRequest,
	RES GetResponse,
] struct {
	TableName  string
	DataColumn string
	Auth       AuthProvider
	AuthJoin   *LeftJoin

	PrimaryKey func(REQ) (map[string]interface{}, error)

	StateResponseField protoreflect.Name

	Join *GetJoinSpec
}

type Getter

type Getter[
	REQ GetRequest,
	RES proto.Message,
] struct {
	// contains filtered or unexported fields
}

func NewGetter

func NewGetter[
	REQ GetRequest,
	RES GetResponse,
](spec GetSpec[REQ, RES]) (*Getter[REQ, RES], error)

func (*Getter[REQ, RES]) Get

func (gc *Getter[REQ, RES]) Get(ctx context.Context, db Transactor, reqMsg REQ, resMsg RES) error

func (*Getter[REQ, RES]) SetQueryLogger

func (gc *Getter[REQ, RES]) SetQueryLogger(logger QueryLogger)

type JoinField

type JoinField struct {
	JoinColumn string // The name of the column in the table being introduced
	RootColumn string // The name of the column in the root table
}

JoinConstraint defines a LEFT JOIN <JoinTable> ON <JoinTable>.<JoinColumn> = <RootTable>.<RootColumn>

type JoinFields

type JoinFields []JoinField

func (JoinFields) Reverse

func (jc JoinFields) Reverse() JoinFields

func (JoinFields) SQL

func (jc JoinFields) SQL(rootAlias string, joinAlias string) string

type LeftJoin

type LeftJoin struct {
	TableName string
	On        JoinFields
}

LeftJoin is a specification for joining in the form <TableName> ON <TableName>.<JoinKeyColumn> = <Main>.<MainKeyColumn> Main is defined in the outer struct holding this LeftJoin

type ListReflectionSet

type ListReflectionSet struct {
	RequestFilterFields []protoreflect.FieldDescriptor
	// contains filtered or unexported fields
}

type ListRequest

type ListRequest interface {
	proto.Message
}

type ListResponse

type ListResponse interface {
	proto.Message
}

type ListSpec

type ListSpec[REQ ListRequest, RES ListResponse] struct {
	TableSpec
	RequestFilter func(REQ) (map[string]interface{}, error)
}

type Lister

type Lister[REQ ListRequest, RES ListResponse] struct {
	ListReflectionSet
	// contains filtered or unexported fields
}

func NewLister

func NewLister[
	REQ ListRequest,
	RES ListResponse,
](spec ListSpec[REQ, RES]) (*Lister[REQ, RES], error)

func (*Lister[REQ, RES]) BuildQuery

func (ll *Lister[REQ, RES]) BuildQuery(ctx context.Context, req protoreflect.Message, res protoreflect.Message) (*sqrl.SelectBuilder, error)

func (*Lister[REQ, RES]) List

func (ll *Lister[REQ, RES]) List(ctx context.Context, db Transactor, reqMsg proto.Message, resMsg proto.Message) error

func (*Lister[REQ, RES]) SetQueryLogger

func (ll *Lister[REQ, RES]) SetQueryLogger(logger QueryLogger)

type QueryLogger

type QueryLogger func(sqrlx.Sqlizer)

type TableSpec

type TableSpec struct {
	TableName string

	Auth     AuthProvider
	AuthJoin []*LeftJoin

	DataColumn string // TODO: Replace with array Columns []Column

	// List of postgres column names to sort by if no other unique sort is found.
	FallbackSortColumns []pgstore.ProtoFieldSpec
}

type Transactor

type Transactor interface {
	Transact(ctx context.Context, opts *sqrlx.TxOptions, callback sqrlx.Callback) error
}

Jump to

Keyboard shortcuts

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