db

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecuteOption

type ExecuteOption func(Statement)

ExecuteOption is an option for statement execution.

type GetAndStartOption

type GetAndStartOption func(*GetAndStartProperty)

GetAndStartOption is an option for GetAndStart.

func GetAndStartWithDBSource

func GetAndStartWithDBSource(source string) GetAndStartOption

GetAndStartWithDBSource specify db source for GetAndStart.

type GetAndStartProperty

type GetAndStartProperty struct {
	Source string
}

GetAndStartProperty is a property for GetAndStart.

type MultipleStatementResult

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

MultipleStatementResult is a results iterator of statement.

func NewMultipleStatementResult

func NewMultipleStatementResult[T any]() *MultipleStatementResult[T]

func (*MultipleStatementResult[T]) Get

func (r *MultipleStatementResult[T]) Get() interface{}

func (*MultipleStatementResult[T]) HasNext

func (r *MultipleStatementResult[T]) HasNext() bool

func (*MultipleStatementResult[T]) Next

func (r *MultipleStatementResult[T]) Next() T

func (*MultipleStatementResult[T]) Set

func (r *MultipleStatementResult[T]) Set(v interface{})

func (*MultipleStatementResult[T]) StrictGet

func (r *MultipleStatementResult[T]) StrictGet() []T

StrictGet returns a results of statement. The return value is a slice of the type specified in the generics.

type Pagination

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

Pagination is a struct for pagination setting.

func (*Pagination) Cursor

func (p *Pagination) Cursor() string

Cursor returns the cursor.

func (*Pagination) IsNextPaging

func (p *Pagination) IsNextPaging() bool

IsNextPaging returns true if this paging is next paging otherwise false.

func (*Pagination) IsPreviousPaging

func (p *Pagination) IsPreviousPaging() bool

IsPreviousPaging returns true if this paging is previous paging otherwise false.

func (*Pagination) Limit

func (p *Pagination) Limit() int

Limit returns the limit.

type PaginationOption

type PaginationOption func(pagination *Pagination)

func WithNextPaging

func WithNextPaging(limit int, cursor *string) PaginationOption

WithNextPaging returns a PaginationOption for next paging.

func WithPreviousPaging

func WithPreviousPaging(limit int, cursor *string) PaginationOption

WithPreviousPaging returns a PaginationOption for previous paging.

type SingleStatementResult

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

SingleStatementResult is a single result of statement.

func NewSingleStatementResult

func NewSingleStatementResult[T any]() *SingleStatementResult[T]

func (*SingleStatementResult[T]) Get

func (r *SingleStatementResult[T]) Get() interface{}

func (*SingleStatementResult[T]) Set

func (r *SingleStatementResult[T]) Set(v interface{})

func (*SingleStatementResult[T]) StrictGet

func (r *SingleStatementResult[T]) StrictGet() T

StrictGet returns a result of statement. The return value is the type specified in the generics.

type Statement

type Statement interface {
	// Execute executes statement.
	Execute(ctx context.Context, opts ...ExecuteOption) error
	Result() StatementResult
}

Statement is a database statement.

e.g. Select, Insert, Update, Delete

type StatementResult

type StatementResult interface {
	// Get returns a result of statement.
	Get() interface{}
	// Set sets a result of statement.
	Set(v interface{})
}

StatementResult is result of statement.

type Transaction

type Transaction interface {
	// ExecuteStatement executes statement in transaction.
	ExecuteStatement(ctx context.Context, statement Statement) error
	// Commit commits transaction.
	Commit(ctx context.Context) error
	// Rollback rollbacks transaction.
	Rollback(ctx context.Context) error
	// SubscribeError returns error channel.
	SubscribeError() <-chan error
}

Transaction is a database transaction.

type TransactionManager

type TransactionManager interface {
	// GetAndStart gets transaction and starts it.
	GetAndStart(ctx context.Context, options ...GetAndStartOption) (Transaction, error)
}

TransactionManager manages transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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