gpa

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEngine

func NewEngine(db *sqlx.DB, cfg Config)

Types

type Condition

type Condition string
const (
	AND Condition = "AND"
	OR  Condition = "OR"
)

type Config added in v0.0.6

type Config struct {
	IsLazy bool
}

type DbProviderI added in v0.0.4

type DbProviderI interface {
	sqlx.Ext
	sqlx.Preparer
	Get(dest interface{}, query string, args ...interface{}) error
	Select(dest interface{}, query string, args ...interface{}) error
	PrepareNamed(query string) (*sqlx.NamedStmt, error)
}

type Engine

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

func (*Engine) GetEntity added in v0.0.4

func (e *Engine) GetEntity(tableName string) (any, bool)

func (*Engine) GetInstance added in v0.0.4

func (e *Engine) GetInstance() DbProviderI

func (*Engine) GetTableName

func (e *Engine) GetTableName(entity any) (string, bool)

func (*Engine) SetTableName

func (e *Engine) SetTableName(entity any, tableName string)

type Entity

type Entity[entityType any] struct {
	// contains filtered or unexported fields
}

func From

func From[entityType any]() *Entity[entityType]

func (*Entity[entityType]) Delete

func (e *Entity[entityType]) Delete(id int64) error

func (*Entity[entityType]) FindAll

func (e *Entity[entityType]) FindAll(p *Pagination) ([]entityType, error)

func (*Entity[entityType]) FindBy

func (e *Entity[entityType]) FindBy(filters []F, p *Pagination) ([]entityType, error)

func (*Entity[entityType]) FindByID

func (e *Entity[entityType]) FindByID(id int64) (entityType, error)

func (*Entity[entityType]) FindOneBy added in v0.0.4

func (e *Entity[entityType]) FindOneBy(filters []F, p *Pagination) (entityType, error)

func (*Entity[entityType]) Get

func (e *Entity[entityType]) Get(where string, args ...interface{}) (entityType, error)

func (*Entity[entityType]) Insert

func (e *Entity[entityType]) Insert(item interface{}) error

func (*Entity[entityType]) Inserts

func (e *Entity[entityType]) Inserts(items []entityType) error

func (*Entity[entityType]) Select

func (e *Entity[entityType]) Select(where string, args ...interface{}) ([]entityType, error)

func (*Entity[entityType]) Update

func (e *Entity[entityType]) Update(entity entityType) error

type EntityMetadataInfo added in v0.0.4

type EntityMetadataInfo struct {
	FieldDb    string
	FieldName  string
	FieldType  reflect.Type
	FieldValue interface{}

	FieldEntity interface{}

	MetaTags MetaTags
}

EntityMetadataInfo MetaData info structure for saving information about field Contains also nested field FieldEntity, which should be the same EntityMetadataInfo type

type F

type F struct {
	FieldName string
	Sign      Sign
	Value     interface{}
	Cond      Condition
}

F Filter

type GPAEntity

type GPAEntity interface {
	GPAConfigure(e *Engine)
}

type MetaDataList added in v0.0.4

type MetaDataList []EntityMetadataInfo

func (MetaDataList) GetDataByDBTag added in v0.0.4

func (m MetaDataList) GetDataByDBTag(dbTag string) EntityMetadataInfo

func (MetaDataList) GetFieldEntity added in v0.0.4

func (m MetaDataList) GetFieldEntity() []interface{}

func (MetaDataList) GetFieldValues added in v0.0.4

func (m MetaDataList) GetFieldValues() interface{}

func (MetaDataList) GetFieldsDb added in v0.0.4

func (m MetaDataList) GetFieldsDb() []string

func (MetaDataList) GetFieldsName added in v0.0.4

func (m MetaDataList) GetFieldsName() []string

func (MetaDataList) GetFieldsType added in v0.0.4

func (m MetaDataList) GetFieldsType() []reflect.Type

func (MetaDataList) GetMappedByMetaJoin added in v0.0.4

func (m MetaDataList) GetMappedByMetaJoin(tableNameMeta string) string

type MetaLazyEntity added in v0.0.4

type MetaLazyEntity struct {
	Idx      int
	Type     reflect.Type
	Join     string
	MappedBy string
	FetchBy  string
}

type MetaTags added in v0.0.4

type MetaTags struct {
	Join     string
	MappedBy string
	Fetch    string
}

type Pagination added in v0.0.2

type Pagination struct {
	Limit  int64
	Offset int64
}

type Sign

type Sign string
const (
	Equal     Sign = "="
	MoreEqual Sign = ">="
	LessEqual Sign = "<="
	More      Sign = ">"
	Less      Sign = "<"
)

Jump to

Keyboard shortcuts

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