repository

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: MIT Imports: 13 Imported by: 0

README

For run integration test with real Postgres (docker container)

make tests

For more information -> Makefile

Documentation

Index

Constants

View Source
const (
	RowsAffectedUnknown = int64(0)
	SerialUnknown       = int64(0)
)
View Source
const (
	FakeStringAns = "fake_string_ans"
)

Variables

View Source
var (
	ErrEmptyRepo = errors.New("repository: emptyRepo, can't found correct Repo by name or obj, please check arguments for methods Repo AutoRepo")
)

Functions

func ConvertIDToInt64

func ConvertIDToInt64(id interface{}) int64

func ConvertIDToString

func ConvertIDToString(id interface{}) string

Types

type Alias

type Alias = string

type Argument

type Argument = interface{}

type Column

type Column = string

type DTO

type DTO = interface{}

type DtoWithIdentity added in v1.2.3

type DtoWithIdentity = interface {
	Identity() ID
}

type ID

type ID = interface{}

type Join

type Join = string

type Query

type Query = string

type Repo

type Repo = Table

type Repositories

type Repositories map[Repo]*repository

func NewSqlxMapRepo

func NewSqlxMapRepo(logger ZapLogger, db SqlxDBConnectorI, tables []Table, objs []DTO) Repositories

func (Repositories) AutoCreate

func (r Repositories) AutoCreate(ctx context.Context, obj DtoWithIdentity) (ID, error)

func (Repositories) AutoDelete

func (r Repositories) AutoDelete(ctx context.Context, obj DtoWithIdentity) (int64, error)

func (Repositories) AutoGet

func (r Repositories) AutoGet(ctx context.Context, obj DtoWithIdentity) error

func (Repositories) AutoRepo

func (r Repositories) AutoRepo(obj DTO) Repository

func (Repositories) AutoUpdate

func (r Repositories) AutoUpdate(ctx context.Context, obj DtoWithIdentity) (int64, error)

func (Repositories) Repo

func (r Repositories) Repo(name Repo) Repository

type RepositoriesI

type RepositoriesI interface {
	Repo(Repo) Repository
	AutoRepo(DTO) Repository

	AutoCreate(context.Context, DtoWithIdentity) (ID, error)
	AutoGet(context.Context, DtoWithIdentity) error
	AutoUpdate(context.Context, DtoWithIdentity) (int64, error)
	AutoDelete(context.Context, DtoWithIdentity) (int64, error)
}

type Repository

type Repository interface {
	// Pure Sqlx Db Connector which we pass to NewSqlxMapRepo
	SqlxDBConnectorI() SqlxDBConnectorI

	// usual "CRUD"
	Create(context.Context, DTO) (ID, error)
	Get(context.Context, ID, DTO) error
	Update(context.Context, ID, DTO) (int64, error)
	Delete(context.Context, ID) (int64, error)

	Insert(context.Context, []Column, []Argument) (int64, error)
	UpdateCustom(context.Context, map[string]interface{}, squirrel.Eq) (int64, error)
	FindBy(context.Context, []Column, squirrel.Eq, DTO) error
	FindByWithInnerJoin(context.Context, []Column, Alias, Join, squirrel.Eq, DTO) error

	GetRowsByQuery(ctx context.Context, qb squirrel.SelectBuilder) (*sql.Rows, error)
	CountByQuery(ctx context.Context, qb squirrel.SelectBuilder) (uint64, error)
}

type Table

type Table = string

type ZapLogger

type ZapLogger = *zap.Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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