orm

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MIT Imports: 6 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// The prefix of an eager loaded relationship
	CtxLoadPrefix ctxKey = iota
	// The alias of an eager loader's parent
	CtxLoadParentAlias
)

Variables

This section is empty.

Functions

func SkipHooks added in v0.2.3

func SkipHooks(ctx context.Context) context.Context

SkipHooks modifies a context to prevent hooks from running for any query it encounters.

Types

type Columns

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

func NewColumns

func NewColumns(names []string) Columns

func (Columns) Except

func (c Columns) Except(cols ...string) Columns

func (Columns) Names added in v0.3.1

func (c Columns) Names() []string

func (Columns) Only

func (c Columns) Only(cols ...string) Columns

func (Columns) WithAggFunc

func (c Columns) WithAggFunc(a, b string) Columns

func (Columns) WithParent

func (c Columns) WithParent(p ...string) Columns

func (Columns) WithPrefix

func (c Columns) WithPrefix(prefix string) Columns

func (Columns) WriteSQL

func (c Columns) WriteSQL(w io.Writer, d bob.Dialect, start int) ([]any, error)

type ExtraLoader

type ExtraLoader struct {
	Fs        []bob.LoadFunc
	OneType   reflect.Type
	SliceType reflect.Type
	// contains filtered or unexported fields
}

func (*ExtraLoader) AppendLoader

func (a *ExtraLoader) AppendLoader(fs ...bob.LoadFunc)

func (*ExtraLoader) Collect

func (a *ExtraLoader) Collect(v any) error

func (*ExtraLoader) LoadMany

func (a *ExtraLoader) LoadMany(ctx context.Context, exec bob.Executor) error

func (*ExtraLoader) LoadOne

func (a *ExtraLoader) LoadOne(ctx context.Context, exec bob.Executor) error

type Hook added in v0.2.3

type Hook[T any] func(context.Context, bob.Executor, T) (context.Context, error)

type Hooks added in v0.2.3

type Hooks[T any] struct {
	// contains filtered or unexported fields
}

func (*Hooks[T]) Add added in v0.2.3

func (h *Hooks[T]) Add(hook Hook[T])

func (*Hooks[T]) Do added in v0.2.3

func (h *Hooks[T]) Do(ctx context.Context, exec bob.Executor, o T) (context.Context, error)

type RelSetDetails added in v0.6.1

type RelSetDetails struct {
	TableName string
	Mapped    []RelSetMapping
}

type RelSetMapping added in v0.6.1

type RelSetMapping struct {
	Column         string
	Value          string
	ExternalTable  string
	ExternalColumn string
}

type RelSide added in v0.2.1

type RelSide struct {
	From        string
	FromColumns []string
	To          string
	ToColumns   []string

	FromWhere, ToWhere []RelWhere

	// If the destination columns contain the key
	// if false, it means the source columns are the foreign key
	ToKey bool
	// if the destination is unique
	ToUnique bool
	// If the key is nullable. We need this to know if we can remove the
	// relationship without deleting it
	KeyNullable bool
}

type RelWhere added in v0.6.1

type RelWhere struct {
	Column string
	Value  string
}

type Relationship

type Relationship struct {
	Name        string
	ByJoinTable bool
	Sides       []RelSide

	Ignored bool // Can be set through user configuration
}

func (Relationship) Foreign added in v0.6.1

func (r Relationship) Foreign() string

func (Relationship) InsertEarly added in v0.6.1

func (r Relationship) InsertEarly() bool

func (Relationship) IsRemovable added in v0.6.1

func (r Relationship) IsRemovable() bool

func (Relationship) IsToMany added in v0.6.1

func (r Relationship) IsToMany() bool

func (Relationship) Local added in v0.6.1

func (r Relationship) Local() string

func (Relationship) NeededColumns added in v0.6.1

func (r Relationship) NeededColumns() []string

func (Relationship) StaticSides added in v0.6.1

func (r Relationship) StaticSides() []struct {
	Table   string
	Columns [][2]string
}

func (Relationship) ValuedSides added in v0.6.1

func (r Relationship) ValuedSides() []RelSetDetails

type RelationshipChainError added in v0.6.1

type RelationshipChainError struct {
	Table1  string
	Column1 string
	Value   string
	Table2  string
	Column2 string
}

func (*RelationshipChainError) Error added in v0.6.1

func (e *RelationshipChainError) Error() string

Directories

Path Synopsis
gen
drivers
Package drivers talks to various database backends and retrieves table, column, type, and foreign key information
Package drivers talks to various database backends and retrieves table, column, type, and foreign key information
importers
Package importers helps with dynamic imports for templating
Package importers helps with dynamic imports for templating

Jump to

Keyboard shortcuts

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