dao

package
v0.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRows              = sql.ErrNoRows
	ErrConstraintViolation = errors.New("constraint violation")
)

Functions

This section is empty.

Types

type AttemptDAO

type AttemptDAO interface {
	BaseDAO[entities.Attempt]
	UpdateStatus(ctx context.Context, id string, status entities.AttemptStatus) error
	UpdateDelivery(ctx context.Context, id string, request *entities.AttemptRequest, response *entities.AttemptResponse, attemptAt time.Time, status entities.AttemptStatus) error
}

func NewAttemptDao

func NewAttemptDao(db *sqlx.DB, workspace bool) AttemptDAO

type BaseDAO

type BaseDAO[T any] interface {
	Get(ctx context.Context, id string) (*T, error)
	Insert(ctx context.Context, entity *T) error
	Update(ctx context.Context, entity *T) error
	Delete(ctx context.Context, id string) (bool, error)
	Page(ctx context.Context, q query.Queryer) ([]*T, int64, error)
	List(ctx context.Context, q query.Queryer) ([]*T, error)
	BatchInsert(ctx context.Context, entities []*T) error
}

type DAO

type DAO[T any] struct {
	// contains filtered or unexported fields
}

func NewDAO

func NewDAO[T any](table string, db *sqlx.DB, workspace bool) *DAO[T]

func (*DAO[T]) BatchInsert

func (dao *DAO[T]) BatchInsert(ctx context.Context, entities []*T) error

func (*DAO[T]) Count

func (dao *DAO[T]) Count(ctx context.Context, where map[string]interface{}) (total int64, err error)

func (*DAO[T]) DB

func (dao *DAO[T]) DB(ctx context.Context) Queryable

func (*DAO[T]) Delete

func (dao *DAO[T]) Delete(ctx context.Context, id string) (bool, error)

func (*DAO[T]) Get

func (dao *DAO[T]) Get(ctx context.Context, id string) (entity *T, err error)

func (*DAO[T]) Insert

func (dao *DAO[T]) Insert(ctx context.Context, entity *T) error

func (*DAO[T]) List

func (dao *DAO[T]) List(ctx context.Context, q query.Queryer) (list []*T, err error)

func (*DAO[T]) Page

func (dao *DAO[T]) Page(ctx context.Context, q query.Queryer) (list []*T, total int64, err error)

func (*DAO[T]) UnsafeDB

func (dao *DAO[T]) UnsafeDB(ctx context.Context) Queryable

func (*DAO[T]) Update

func (dao *DAO[T]) Update(ctx context.Context, entity *T) error

type EndpointDAO

type EndpointDAO interface {
	BaseDAO[entities.Endpoint]
}

func NewEndpointDAO

func NewEndpointDAO(db *sqlx.DB, workspace bool) EndpointDAO

type EventDAO

type EventDAO interface {
	BaseDAO[entities.Event]
}

func NewEventDao

func NewEventDao(db *sqlx.DB, workspace bool) EventDAO

type Queryable

type Queryable interface {
	sqlx.ExtContext
	GetContext(context.Context, interface{}, string, ...interface{}) error
	SelectContext(context.Context, interface{}, string, ...interface{}) error
}

Queryable is an interface to be used interchangeably for sqlx.Db and sqlx.Tx

type SourceDAO

type SourceDAO interface {
	BaseDAO[entities.Source]
}

func NewSourceDAO

func NewSourceDAO(db *sqlx.DB, workspace bool) SourceDAO

type WorkspaceDAO

type WorkspaceDAO interface {
	BaseDAO[entities.Workspace]
	GetDefault(ctx context.Context) (*entities.Workspace, error)
}

func NewWorkspaceDAO

func NewWorkspaceDAO(db *sqlx.DB) WorkspaceDAO

Jump to

Keyboard shortcuts

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