j5query

package
v0.0.0-...-0f19e00 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 29 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPathSortable

func IsPathSortable(path *Path) bool

func WalkPathNodes

func WalkPathNodes(rootMessage *j5schema.ObjectSchema, callback func(Path) error) error

WalkPathNodes visits every field in the message tree other than the root message itself, calling the callback for each.

Types

type AuthProvider

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

type AuthProviderFunc

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

func (AuthProviderFunc) AuthFilter

func (f AuthProviderFunc) AuthFilter(ctx context.Context) (map[string]string, 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 element,
	MountPoint *Path
}

type GetJoinSpec

type GetJoinSpec struct {
	TableName     string
	DataColumn    string
	On            JoinFields
	FieldInParent string
}

type GetRequest

type GetRequest interface {
	j5reflect.Object
}

type GetResponse

type GetResponse interface {
	j5reflect.Object
}

type GetSpec

type GetSpec struct {
	Method *j5schema.MethodSchema

	TableName  string
	DataColumn string
	Auth       AuthProvider
	AuthJoin   []*LeftJoin

	PrimaryKey func(j5reflect.Object) (map[string]any, error)

	StateResponseField string

	Join *GetJoinSpec
}

type Getter

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

func NewGetter

func NewGetter(spec GetSpec) (*Getter, error)

func (*Getter) Get

func (gc *Getter) Get(ctx context.Context, db Transactor, reqMsg, resMsg j5reflect.Object) error

func (*Getter) SetQueryLogger

func (gc *Getter) SetQueryLogger(logger QueryLogger)

type JSONPathSpec

type JSONPathSpec []string

Like ProtoPathSpec but uses JSON field names

func JSONPath

func JSONPath(path ...string) JSONPathSpec

func ParseJSONPathSpec

func ParseJSONPathSpec(path string) JSONPathSpec

func (JSONPathSpec) String

func (jp JSONPathSpec) String() string

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 {
	TableReflectionSet

	RequestFilterFields []*j5schema.ObjectProperty
	// contains filtered or unexported fields
}

func BuildListReflection

func BuildListReflection(method *j5schema.MethodSchema, table TableSpec) (*ListReflectionSet, error)

type ListRequest

type ListRequest interface {
	j5reflect.Object
}

type ListResponse

type ListResponse interface {
	j5reflect.Object
}

type ListRules

type ListRules struct {
	Sort   *list_j5pb.SortingConstraint
	Filter *list_j5pb.FilteringConstraint
	Search *list_j5pb.SearchingConstraint
}

func FieldListRules

func FieldListRules(path *Path) *ListRules

type ListSpec

type ListSpec struct {
	Method *j5schema.MethodSchema

	TableSpec
	RequestFilter func(j5reflect.Object) (map[string]any, error)
}

func (*ListSpec) Validate

func (ls *ListSpec) Validate() error

type Lister

type Lister struct {
	ListReflectionSet
	// contains filtered or unexported fields
}

func NewLister

func NewLister(spec ListSpec) (*Lister, error)

func (*Lister) BuildQuery

func (ll *Lister) BuildQuery(ctx context.Context, req j5reflect.Object, res j5reflect.Object) (*Query, error)

func (*Lister) List

func (ll *Lister) List(ctx context.Context, db Transactor, req, res j5reflect.Object) error

func (*Lister) SetQueryLogger

func (ll *Lister) SetQueryLogger(logger QueryLogger)

type NestedField

type NestedField struct {

	// The column containing the element JSONB
	RootColumn string

	// The path from the column root to the node
	Path Path

	// ValueColumn contains the value of the field directly in the table in
	// addition to nested within the JSONB data.
	ValueColumn *string
}

func (*NestedField) ProtoChild

func (nf *NestedField) ProtoChild(name string) (*NestedField, error)

func (*NestedField) Selector

func (nf *NestedField) Selector(inTable string) string

type Path

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

func NewJSONPath

func NewJSONPath(rootMessage *j5schema.ObjectSchema, fieldPath JSONPathSpec) (*Path, error)

func NewProtoPath

func NewProtoPath(rootMessage *j5schema.ObjectSchema, fieldPath ProtoPathSpec) (*Path, error)

func (Path) Child

func (pp Path) Child(name string) (*Path, error)

func (Path) ClientPath

func (pp Path) ClientPath() string

func (Path) DebugName

func (pp Path) DebugName() string

func (*Path) GetValue

func (pp *Path) GetValue(msg j5reflect.Object) (any, bool, error)

func (Path) IDPath

func (pp Path) IDPath() string

IDPath uniquely identifies the path within a specific root type context

func (*Path) JSONBArrowPath

func (pp *Path) JSONBArrowPath() string

func (*Path) JSONPathQuery

func (pp *Path) JSONPathQuery() string

func (Path) LeafField

func (pp Path) LeafField() *j5schema.ObjectProperty

func (Path) LeafOneof

func (pp Path) LeafOneof() *j5schema.OneofSchema

func (Path) Root

func (pp Path) Root() *j5schema.ObjectSchema

func (Path) WalkPathNodes

func (pp Path) WalkPathNodes(callback func(*j5schema.ObjectProperty) bool)

WalkPathNodes visits every field in the path other than the leaf field itself, calling the callback for each. Walking stops if the callback returns false.

type ProtoField

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

ProtoField represents a field within a the root data.

func NewJSONField

func NewJSONField(protoPath string, columnName *string) ProtoField

type ProtoPathSpec

type ProtoPathSpec []string

type Query

type Query struct {
	*sq.SelectBuilder
	// contains filtered or unexported fields
}

func (*Query) AddRootColumn

func (ll *Query) AddRootColumn()

func (*Query) J5LeftJoinRoot

func (ll *Query) J5LeftJoinRoot(newTable string, joinFields ...string) string

type QueryLogger

type QueryLogger func(sqrlx.Sqlizer)

type TSVColumn

type TSVColumn struct {
	Path
	ColumnName string
}

func TSVColumns

func TSVColumns(message *j5schema.ObjectSchema) ([]*TSVColumn, error)

type Table

type Table interface {
	TableName() string
}

type TableReflectionSet

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

func NewTableReflectionSet

func NewTableReflectionSet(table TableSpec) (*TableReflectionSet, error)

func (*TableReflectionSet) ArrayObject

func (ll *TableReflectionSet) ArrayObject() *j5schema.ObjectSchema

func (*TableReflectionSet) BuildQuery

func (ll *TableReflectionSet) BuildQuery(ctx context.Context, reqQuery *list_j5pb.QueryRequest) (*Query, error)

type TableSpec

type TableSpec struct {
	TableName string

	Auth     AuthProvider
	AuthJoin []*LeftJoin

	DataColumn string // TODO: Replace with array Columns []Column
	RootObject *j5schema.ObjectSchema

	// List of fields to sort by if no other unique sort is found.
	FallbackSortColumns []ProtoField
}

func (*TableSpec) Validate

func (ts *TableSpec) Validate() error

type Transactor

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

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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