repo

package
v0.0.0-...-0640eb1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoOrderBy = OrderByParams{}

NoOrderBy represents default ordering (no order specified)

Functions

func BoolPtrFromNullableBool

func BoolPtrFromNullableBool(sqlBool sql.NullBool) *bool

BoolPtrFromNullableBool missing godoc

func IntPtrFromNullableInt

func IntPtrFromNullableInt(i sql.NullInt32) *int

IntPtrFromNullableInt missing godoc

func JSONRawMessageFromNullableString

func JSONRawMessageFromNullableString(sqlString sql.NullString) json.RawMessage

JSONRawMessageFromNullableString missing godoc

func NewNullableBool

func NewNullableBool(boolean *bool) sql.NullBool

NewNullableBool missing godoc

func NewNullableInt

func NewNullableInt(i *int) sql.NullInt32

NewNullableInt missing godoc

func NewNullableString

func NewNullableString(text *string) sql.NullString

NewNullableString missing godoc

func NewNullableStringFromJSONRawMessage

func NewNullableStringFromJSONRawMessage(json json.RawMessage) sql.NullString

NewNullableStringFromJSONRawMessage missing godoc

func NewValidNullableBool

func NewValidNullableBool(boolean bool) sql.NullBool

NewValidNullableBool missing godoc

func NewValidNullableString

func NewValidNullableString(text string) sql.NullString

NewValidNullableString missing godoc

func StringPtrFromNullableString

func StringPtrFromNullableString(sqlString sql.NullString) *string

StringPtrFromNullableString missing godoc

Types

type BaseEntity

type BaseEntity struct {
	ID        string         `db:"id"`
	Ready     bool           `db:"ready"`
	CreatedAt *time.Time     `db:"created_at"`
	UpdatedAt *time.Time     `db:"updated_at"`
	DeletedAt *time.Time     `db:"deleted_at"`
	Error     sql.NullString `db:"error"`
}

BaseEntity missing godoc

func (*BaseEntity) GetCreatedAt

func (e *BaseEntity) GetCreatedAt() time.Time

GetCreatedAt missing godoc

func (*BaseEntity) GetDeletedAt

func (e *BaseEntity) GetDeletedAt() time.Time

GetDeletedAt missing godoc

func (*BaseEntity) GetError

func (e *BaseEntity) GetError() sql.NullString

GetError missing godoc

func (*BaseEntity) GetReady

func (e *BaseEntity) GetReady() bool

GetReady missing godoc

func (*BaseEntity) GetUpdatedAt

func (e *BaseEntity) GetUpdatedAt() time.Time

GetUpdatedAt missing godoc

func (*BaseEntity) SetCreatedAt

func (e *BaseEntity) SetCreatedAt(t time.Time)

SetCreatedAt missing godoc

func (*BaseEntity) SetDeletedAt

func (e *BaseEntity) SetDeletedAt(t time.Time)

SetDeletedAt missing godoc

func (*BaseEntity) SetError

func (e *BaseEntity) SetError(err sql.NullString)

SetError missing godoc

func (*BaseEntity) SetReady

func (e *BaseEntity) SetReady(ready bool)

SetReady missing godoc

func (*BaseEntity) SetUpdatedAt

func (e *BaseEntity) SetUpdatedAt(t time.Time)

SetUpdatedAt missing godoc

type Collection

type Collection interface {
	Len() int
}

Collection missing godoc

type Condition

type Condition interface {
	// GetQueryPart returns formatted string that will be included in the SQL query for a given condition
	GetQueryPart() string

	// GetQueryArg returns a boolean flag if the condition contains argument and the argument value
	//
	// For conditions like IN and IS NOT NULL there are no arguments to be included in the query.
	// For conditions like = there is a placeholder which value will be returned calling this func.
	GetQueryArgs() ([]interface{}, bool)
}

Condition missing godoc

func NewEqualCondition

func NewEqualCondition(field string, val interface{}) Condition

NewEqualCondition missing godoc

func NewInConditionForStringValues

func NewInConditionForStringValues(field string, values []string) Condition

NewInConditionForStringValues missing godoc

func NewInConditionForSubQuery

func NewInConditionForSubQuery(field, subQuery string, args []interface{}) Condition

NewInConditionForSubQuery missing godoc

func NewJSONArrAnyMatchCondition

func NewJSONArrAnyMatchCondition(field string, val []interface{}) Condition

NewJSONArrAnyMatchCondition missing godoc

func NewJSONArrMatchAnyStringCondition

func NewJSONArrMatchAnyStringCondition(field string, values ...string) Condition

NewJSONArrMatchAnyStringCondition missing godoc

func NewJSONCondition

func NewJSONCondition(field string, val interface{}) Condition

NewJSONCondition missing godoc

func NewNotEqualCondition

func NewNotEqualCondition(field string, val interface{}) Condition

NewNotEqualCondition missing godoc

func NewNotNullCondition

func NewNotNullCondition(field string) Condition

NewNotNullCondition missing godoc

func NewNotRegexConditionString

func NewNotRegexConditionString(field string, value string) Condition

NewNotRegexConditionString missing godoc

func NewNullCondition

func NewNullCondition(field string) Condition

NewNullCondition missing godoc

func NewTenantIsolationCondition

func NewTenantIsolationCondition(field string, val interface{}) Condition

NewTenantIsolationCondition returns a repo condition filtering all resources based on the tenant provided (recursively iterating over all the child tenants)

func NewTenantIsolationConditionWithPlaceholder

func NewTenantIsolationConditionWithPlaceholder(field string, placeholder string, args []interface{}) Condition

NewTenantIsolationConditionWithPlaceholder return tenant isolation repo condition with different tenant_id input placeholder. This is needed for update sql queries where the tenant_id to search for is not provided as an argument, but is used from the entity being updated.

type Conditions

type Conditions []Condition

Conditions missing godoc

type Creator

type Creator interface {
	Create(ctx context.Context, dbEntity interface{}) error
}

Creator missing godoc

func NewCreator

func NewCreator(resourceType resource.Type, tableName string, columns []string) Creator

NewCreator missing godoc

type Deleter

type Deleter interface {
	DeleteOne(ctx context.Context, tenant string, conditions Conditions) error
	DeleteMany(ctx context.Context, tenant string, conditions Conditions) error
}

Deleter missing godoc

func NewDeleter

func NewDeleter(resourceType resource.Type, tableName string, tenantColumn string) Deleter

NewDeleter missing godoc

type DeleterGlobal

type DeleterGlobal interface {
	DeleteOneGlobal(ctx context.Context, conditions Conditions) error
	DeleteManyGlobal(ctx context.Context, conditions Conditions) error
}

DeleterGlobal missing godoc

func NewDeleterGlobal

func NewDeleterGlobal(resourceType resource.Type, tableName string) DeleterGlobal

NewDeleterGlobal missing godoc

type Entity

type Entity interface {
	GetReady() bool
	SetReady(ready bool)

	GetCreatedAt() time.Time
	SetCreatedAt(t time.Time)

	GetUpdatedAt() time.Time
	SetUpdatedAt(t time.Time)

	GetDeletedAt() time.Time
	SetDeletedAt(t time.Time)

	GetError() sql.NullString
	SetError(err sql.NullString)
}

Entity denotes an DB-layer entity which can be timestamped with created_at, updated_at, deleted_at and ready values

type ExistQuerier

type ExistQuerier interface {
	Exists(ctx context.Context, tenant string, conditions Conditions) (bool, error)
}

ExistQuerier missing godoc

func NewExistQuerier

func NewExistQuerier(resourceType resource.Type, tableName string, tenantColumn string) ExistQuerier

NewExistQuerier missing godoc

type ExistQuerierGlobal

type ExistQuerierGlobal interface {
	ExistsGlobal(ctx context.Context, conditions Conditions) (bool, error)
}

ExistQuerierGlobal missing godoc

func NewExistQuerierGlobal

func NewExistQuerierGlobal(resourceType resource.Type, tableName string) ExistQuerierGlobal

NewExistQuerierGlobal missing godoc

type GroupByParams

type GroupByParams []string

GroupByParams missing godoc

type Lister

type Lister interface {
	List(ctx context.Context, tenant string, dest Collection, additionalConditions ...Condition) error
	SetSelectedColumns(selectedColumns []string)
	Clone() Lister
}

Lister missing godoc

func NewLister

func NewLister(resourceType resource.Type, tableName string, tenantColumn string, selectedColumns []string) Lister

NewLister missing godoc

func NewListerWithOrderBy

func NewListerWithOrderBy(resourceType resource.Type, tableName string, tenantColumn string, selectedColumns []string, orderByParams OrderByParams) Lister

NewListerWithOrderBy missing godoc

type ListerGlobal

type ListerGlobal interface {
	ListGlobal(ctx context.Context, dest Collection, additionalConditions ...Condition) error
}

ListerGlobal missing godoc

func NewListerGlobal

func NewListerGlobal(resourceType resource.Type, tableName string, selectedColumns []string) ListerGlobal

NewListerGlobal missing godoc

type OrderBy

type OrderBy struct {
	Field string
	Dir   OrderByDir
}

OrderBy type that wraps the information about the ordering column and direction

func NewAscOrderBy

func NewAscOrderBy(field string) OrderBy

NewAscOrderBy returns wrapping type for ascending order for a given column (field)

func NewDescOrderBy

func NewDescOrderBy(field string) OrderBy

NewDescOrderBy returns wrapping type for descending orderd for a given column (field)

type OrderByDir

type OrderByDir string

OrderByDir is a type encapsulating the ORDER BY direction

const (
	// AscOrderBy defines ascending order
	AscOrderBy OrderByDir = "ASC"
	// DescOrderBy defines descending order
	DescOrderBy OrderByDir = "DESC"
)

type OrderByParams

type OrderByParams []OrderBy

OrderByParams is a wrapping type for slice of OrderBy types

type PageableQuerier

type PageableQuerier interface {
	List(ctx context.Context, tenant string, pageSize int, cursor string, orderByColumn string, dest Collection, additionalConditions ...Condition) (*pagination.Page, int, error)
}

PageableQuerier missing godoc

func NewPageableQuerier

func NewPageableQuerier(resourceType resource.Type, tableName string, tenantColumn string, selectedColumns []string) PageableQuerier

NewPageableQuerier missing godoc

type PageableQuerierGlobal

type PageableQuerierGlobal interface {
	ListGlobal(ctx context.Context, pageSize int, cursor string, orderByColumn string, dest Collection, additionalConditions ...Condition) (*pagination.Page, int, error)
}

PageableQuerierGlobal missing godoc

func NewPageableQuerierGlobal

func NewPageableQuerierGlobal(resourceType resource.Type, tableName string, selectedColumns []string) PageableQuerierGlobal

NewPageableQuerierGlobal missing godoc

type QueryBuilder

type QueryBuilder interface {
	BuildQuery(tenantID string, isRebindingNeeded bool, conditions ...Condition) (string, []interface{}, error)
}

QueryBuilder missing godoc

func NewQueryBuilder

func NewQueryBuilder(resourceType resource.Type, tableName string, tenantColumn string, selectedColumns []string) QueryBuilder

NewQueryBuilder missing godoc

type SingleGetter

type SingleGetter interface {
	Get(ctx context.Context, tenant string, conditions Conditions, orderByParams OrderByParams, dest interface{}) error
}

SingleGetter missing godoc

func NewSingleGetter

func NewSingleGetter(resourceType resource.Type, tableName string, tenantColumn string, selectedColumns []string) SingleGetter

NewSingleGetter missing godoc

type SingleGetterGlobal

type SingleGetterGlobal interface {
	GetGlobal(ctx context.Context, conditions Conditions, orderByParams OrderByParams, dest interface{}) error
}

SingleGetterGlobal missing godoc

func NewSingleGetterGlobal

func NewSingleGetterGlobal(resourceType resource.Type, tableName string, selectedColumns []string) SingleGetterGlobal

NewSingleGetterGlobal missing godoc

type UnionLister

type UnionLister interface {
	// List stores the result into dest and returns the total count of tuples for each id from ids
	List(ctx context.Context, tenant string, ids []string, idsColumn string, pageSize int, cursor string, orderBy OrderByParams, dest Collection, additionalConditions ...Condition) (map[string]int, error)
	SetSelectedColumns(selectedColumns []string)
	Clone() UnionLister
}

UnionLister missing godoc

func NewUnionLister

func NewUnionLister(resourceType resource.Type, tableName string, tenantColumn string, selectedColumns []string) UnionLister

NewUnionLister missing godoc

type Updater

type Updater interface {
	UpdateSingle(ctx context.Context, dbEntity interface{}) error
	SetIDColumns(idColumns []string)
	SetUpdatableColumns(updatableColumns []string)
	Clone() Updater
	TechnicalUpdate(ctx context.Context, dbEntity interface{}) error
}

Updater missing godoc

func NewUpdater

func NewUpdater(resourceType resource.Type, tableName string, updatableColumns []string, tenantColumn string, idColumns []string) Updater

NewUpdater missing godoc

type UpdaterGlobal

type UpdaterGlobal interface {
	UpdateSingleGlobal(ctx context.Context, dbEntity interface{}) error
}

UpdaterGlobal missing godoc

func NewUpdaterGlobal

func NewUpdaterGlobal(resourceType resource.Type, tableName string, updatableColumns []string, idColumns []string) UpdaterGlobal

NewUpdaterGlobal missing godoc

type Upserter

type Upserter interface {
	Upsert(ctx context.Context, dbEntity interface{}) error
}

Upserter missing godoc

func NewUpserter

func NewUpserter(resourceType resource.Type, tableName string, insertColumns []string, conflictingColumns []string, updateColumns []string) Upserter

NewUpserter missing godoc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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