relational

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EqualOperator              = Operator{"="}
	GreaterThanOperator        = Operator{">"}
	LessThanOperator           = Operator{"<"}
	GreaterThanOrEqualOperator = Operator{">="}
	LessThanOrEqualOperator    = Operator{"<="}
	NotEqualOperator           = Operator{"!="}
	InOperator                 = Operator{"IN"}
	BetweenOperator            = Operator{"BETWEEN"}
	LikeOperator               = Operator{"LIKE"}
	ILikeOperator              = Operator{"ILIKE"}
	IsNullOperator             = Operator{"IS NULL"}
	IsNotNullOperator          = Operator{"IS NOT NULL"}
	NotOperator                = Operator{"NOT"}
)
View Source
var (
	AndOperator = LogicalOperator{"AND"}
	OrOperator  = LogicalOperator{"OR"}
)

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Column     string
	Comparison Operator
	LogOp      LogicalOperator
	Value      interface{}
}

type ConditionGroup

type ConditionGroup struct {
	Conditions []Condition
	LogOp      LogicalOperator
}

type DB

type DB struct {
	*bun.DB
}

func (*DB) AddDateFilters

func (db *DB) AddDateFilters(query *bun.SelectQuery, filters []DateFilter) *bun.SelectQuery

func (*DB) AddKeysetPagination added in v1.2.0

func (db *DB) AddKeysetPagination(query *bun.SelectQuery, limit int, cursors ...ConditionGroup) (*bun.SelectQuery, error)

func (*DB) AddLimitAndOffset

func (db *DB) AddLimitAndOffset(query *bun.SelectQuery, limit, offset int) *bun.SelectQuery

TODO: Deprecate

func (*DB) AddOffsetPagination added in v1.2.0

func (db *DB) AddOffsetPagination(query *bun.SelectQuery, limit, offset int) *bun.SelectQuery

func (*DB) CreateExtensions

func (db *DB) CreateExtensions(extensions []string) error

CreateExtensions - Creates a database extension if it doesn't already exist

func (*DB) CreateTables

func (db *DB) CreateTables(models []interface{}) error

CreateTables - Creates the database schema if it doesn't already exist

func (*DB) QueryBuilder

func (db *DB) QueryBuilder(groups []ConditionGroup) (query string, queryArgs []interface{}, err error)

func (*DB) QueryCount

func (db *DB) QueryCount(ctx context.Context, model interface{}, query string, conditions ...interface{}) (int, error)

func (*DB) RegisterModels

func (db *DB) RegisterModels(models []interface{}) error

RegisterModels - Registers many-to-many relationship

func (*DB) ResetTables

func (db *DB) ResetTables(models []interface{}) error

ResetTables - Drops and recreates the database schema

type DateFilter

type DateFilter struct {
	DateColumn   string `json:"date_column"`
	FromDate     string `json:"from_date"`
	ToDate       string `json:"to_date"`
	FromDateUnix int64  `json:"-"`
	ToDateUnix   int64  `json:"-"`
}

func (*DateFilter) ParseToUnix added in v1.1.1

func (df *DateFilter) ParseToUnix(validDBColumns []string) error

type LogicalOperator

type LogicalOperator struct {
	Value string
}

func (LogicalOperator) String

func (s LogicalOperator) String() string

type Operator

type Operator struct {
	Value string
}

func (Operator) String

func (s Operator) String() string

type Option

type Option func(db *DB) error

func WithExtensions

func WithExtensions(extensions []string) Option

func WithRegistrableModels

func WithRegistrableModels(models []interface{}) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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