db

package
v0.0.0-...-4ad1eb6 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatabase

func NewDatabase(c Config) *gorm.DB

Types

type CollectionQuery

type CollectionQuery struct {
	FilterQuery
	// contains filtered or unexported fields
}

func NewCollectionQuery

func NewCollectionQuery(model interface{}) *CollectionQuery

func (*CollectionQuery) SetSlice

func (q *CollectionQuery) SetSlice(slice *Slice)

func (*CollectionQuery) Slice

func (q *CollectionQuery) Slice() *Slice

type Config

type Config struct {
	Host         string `envconfig:"DB_HOST"`
	Driver       string `envconfig:"DB_DRIVER"`
	DatabaseName string `envconfig:"DB_NAME"`
	User         string `envconfig:"DB_USER"`
	Password     string `envconfig:"DB_PASSWORD"`
	Port         string `envconfig:"DB_PORT"`
	Logging      string `envconfig:"DB_LOGGING"`
}

type DefaultRepositoryNotSetErr

type DefaultRepositoryNotSetErr struct {
}

func NewDefaultRepositoryNotSetErr

func NewDefaultRepositoryNotSetErr() DefaultRepositoryNotSetErr

func (DefaultRepositoryNotSetErr) Error

type Direction

type Direction string
const (
	ASC  Direction = "asc"
	DESC Direction = "desc"
)

type Filter

type Filter struct {
	FieldName string
	Operator  string
	Value     interface{}
}

type FilterQuery

type FilterQuery struct {
	Query
	// contains filtered or unexported fields
}

func NewFilterQuery

func NewFilterQuery(model interface{}) *FilterQuery

func (*FilterQuery) Filters

func (q *FilterQuery) Filters() []Filter

func (*FilterQuery) SetFilters

func (q *FilterQuery) SetFilters(filters []Filter)

type FilteredQueryObject

type FilteredQueryObject interface {
	QueryObject
	Filters() []Filter
}

type JSON

type JSON json.RawMessage

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

Scan value into Jsonb, implements sql.Scanner interface

func (*JSON) Value

func (j *JSON) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type Preload

type Preload struct {
	Name       string
	Conditions []interface{}
}

type Query

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

func NewQuery

func NewQuery(model interface{}) *Query

func (*Query) AddPreload

func (q *Query) AddPreload(preload Preload)

func (*Query) Error

func (q *Query) Error() error

func (*Query) Model

func (q *Query) Model() interface{}

func (*Query) Preloads

func (q *Query) Preloads() []Preload

func (*Query) Result

func (q *Query) Result() interface{}

func (*Query) SetError

func (q *Query) SetError(err error)

func (*Query) SetModel

func (q *Query) SetModel(model interface{})

func (*Query) SetPreloads

func (q *Query) SetPreloads(preloads *[]Preload)

func (*Query) SetResult

func (q *Query) SetResult(result interface{})

func (*Query) Type

func (q *Query) Type() string

type QueryHandler

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

func NewQueryHandler

func NewQueryHandler(db *gorm.DB) *QueryHandler

func (*QueryHandler) Handle

func (h *QueryHandler) Handle(query QueryObject) QueryObject

func (*QueryHandler) Supports

func (h *QueryHandler) Supports(t interface{}) bool

type QueryManager

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

func NewQueryManager

func NewQueryManager(db *gorm.DB) *QueryManager

func (*QueryManager) DB

func (m *QueryManager) DB() *gorm.DB

func (*QueryManager) Default

func (m *QueryManager) Default() (Repository, error)

func (*QueryManager) Get

func (m *QueryManager) Get(t interface{}) (Repository, error)

func (*QueryManager) Register

func (m *QueryManager) Register(r Repository)

type QueryObject

type QueryObject interface {
	Model() interface{}
	Error() error
	SetError(err error)
	Result() interface{}
	SetResult(result interface{})
	Preloads() []Preload
}

type Repository

type Repository interface {
	Handle(q QueryObject) QueryObject
	Supports(t interface{}) bool
}

type RepositoryNotFoundErr

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

func NewRepositoryNotFound

func NewRepositoryNotFound(t interface{}) RepositoryNotFoundErr

func (RepositoryNotFoundErr) Error

func (e RepositoryNotFoundErr) Error() string

type Slice

type Slice struct {
	Offset int
	Limit  int
	Total  int64
	Sort   []Sort
}

type SlicedQueryObject

type SlicedQueryObject interface {
	FilteredQueryObject
	Slice() *Slice
}

type Sort

type Sort struct {
	FieldName string
	Direction Direction
}

type UnsupportedQueryTypeErr

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

func (UnsupportedQueryTypeErr) Error

func (e UnsupportedQueryTypeErr) Error() string

Jump to

Keyboard shortcuts

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