efeqt

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Insert = "INSERT"
	Update = "UPDATE"
)
View Source
const (
	SortUp   = "ASC"
	SortDown = "DESC"
)
View Source
const (
	Id = "id"
)
View Source
const (
	TsVectorDataType = "TSVECTOR"
)

Variables

View Source
var (
	ErrorMissingPrimaryKey   = errors.New("missing primary key")
	ErrorMissingDatabase     = errors.New("missing database connection")
	ErrorMismatchQueryTarget = errors.New("mismatch query target len with builders")
	ErrorTargetNoPtr         = errors.New("query target is not a pointer")
	ErrorInvalidMap          = errors.New("invalid map type, needs to be map[string]any")
)

Functions

func CreateFieldsTsVector

func CreateFieldsTsVector(values Map, fields ...Field) string

func Entity

func Entity[E entity](override ...Override) *E

func TsVector

func TsVector(values ...any) string

Types

type BuildResult

type BuildResult struct {
	Sql    string
	Values map[string]any
}

type DuplicatesBuilder

type DuplicatesBuilder interface {
	QueryBuilder
	Prevent(fields ...QueryBuilder) ShapeBuilder
	Remove(remove ...bool) ShapeBuilder
}

type EntityBuilder

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

func (EntityBuilder) Field

func (b EntityBuilder) Field(name string) Field

type EntityMigrator

type EntityMigrator interface {
	Cascade(cascade ...bool) EntityMigrator
	GetUpSql() string
	GetDownSql() string
	Up() error
	Down() error

	MustUp()
	MustDown()
}

func Migrate

func Migrate[E entity](db *esquel.DB) EntityMigrator

type Field

type Field interface {
	QueryBuilder
	Default(value any) Field
	NotNull(notNull ...bool) Field
	Prefix(prefix string) Field
	PrimaryKey(primaryKey ...bool) Field
	Type(dataType string) Field
	Unique(unique ...bool) Field
	Relationship(relationship Field) Field
	CreateValue(fn func(operation string, values Map) Value) Field
	Name() string
	TsVector() Field
	Serial() Field
	Bool() Field
	Char(n int) Field
	Varchar(n int) Field
	Jsonb() Field
	Int() Field
	Float() Field
	Timestamp() Field
	Timestampz() Field
}

type FilterBuilder

type FilterBuilder interface {
	QueryBuilder
	Group(builders ...FilterBuilder) FilterBuilder
	Field(field QueryBuilder) FilterBuilder
	Equal(equal ...bool) FilterBuilder
	Is() FilterBuilder
	In(in ...bool) FilterBuilder
	Value(value any, name ...string) FilterBuilder
	Gt() FilterBuilder
	Gte() FilterBuilder
	Lt() FilterBuilder
	Lte() FilterBuilder
	Match() FilterBuilder
	Not(not ...bool) FilterBuilder
	TsQuery(values ...any) FilterBuilder
	Null() FilterBuilder
}

func Filter

func Filter(modifiers ...Modifier) FilterBuilder

type FindRepository

type FindRepository interface {
	QueryBuilder
	Run(result any, runner ...Runner) error
	MustRun(result any, runner ...Runner)
}

type Map

type Map = map[string]any

type Modifier

type Modifier interface {
	Type() string
}

func After

func After(use ...bool) Modifier

func Or

func Or(use ...bool) Modifier

type Override

type Override struct {
	Table string
	Alias string
}

type QueryBuilder

type QueryBuilder interface {
	Build() BuildResult
}

func Fragment

func Fragment(builders ...QueryBuilder) QueryBuilder

func If

func If(condition bool, qb QueryBuilder) QueryBuilder

func Use

func Use(values any) QueryBuilder

type RelationshipBuilder

type RelationshipBuilder interface {
	QueryBuilder
	Keep() RelationshipBuilder
	Prefer() RelationshipBuilder
	Intersect() RelationshipBuilder
	Unify() RelationshipBuilder
	Combine() RelationshipBuilder
}

func Relationship

func Relationship(relationshipField Field) RelationshipBuilder

type RemoveRepository

type RemoveRepository interface {
	QueryBuilder
	Run(result any, runner ...Runner) error
	MustRun(result any, runner ...Runner)
}

type RepositoryManager

type RepositoryManager[E entity] interface {
	Find(builders ...QueryBuilder) FindRepository
	Save(builders ...QueryBuilder) SaveRepository
	Remove(builders ...QueryBuilder) RemoveRepository
}

func Repository

func Repository[E entity](db *esquel.DB) RepositoryManager[E]

type Runner

type Runner interface {
	Add(builders ...QueryBuilder)
	AllInSequence(target ...any) error
	AllInParallel(target ...any) error
	MustAllInSequence(target ...any)
	MustAllInParallel(target ...any)
}

func Run

func Run(db *esquel.DB) Runner

type Safe

type Safe = esquel.Safe

type SaveRepository

type SaveRepository interface {
	QueryBuilder
	Run(result any, runner ...Runner) error
	MustRun(result any, runner ...Runner)
	ForceInsert() SaveRepository
}

type ShapeBuilder

type ShapeBuilder interface {
	QueryBuilder
	Start(start int) ShapeBuilder
	Max(max int) ShapeBuilder
	Duplicates() DuplicatesBuilder
	Sort(aliases ...map[string]Field) SortBuilder
}

func Shape

func Shape() ShapeBuilder

type SortBuilder

type SortBuilder interface {
	QueryBuilder
	Use(sorters ...Sorter) SortBuilder
	Up(field QueryBuilder) SortBuilder
	Down(field QueryBuilder) SortBuilder
}

type Sorter

type Sorter struct {
	Field     string `json:"field"`
	Direction string `json:"direction"`
}

type TemporaryBuilder

type TemporaryBuilder interface {
	QueryBuilder
}

func Temporary

func Temporary(name string, qb QueryBuilder) TemporaryBuilder

type Value

type Value any

Jump to

Keyboard shortcuts

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