sqlDB

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const SqlTxContext = "SqlTxContext"

Variables

This section is empty.

Functions

func Initialize

func Initialize()

Initialize start connection with sql database and execute migration

func NewTransaction

func NewTransaction(isolation ...sql.IsolationLevel) transaction.Transaction

NewTransaction creates new sqlTransaction with implements a transaction.Transaction

Types

type PageQuery

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

PageQuery struct

func NewPageQuery

func NewPageQuery[T any](ctx context.Context, page *types.PageRequest, query string, params ...interface{}) *PageQuery[T]

NewPageQuery create a new pointer to PageQuery struct

func (*PageQuery[T]) Execute

func (q *PageQuery[T]) Execute() (*types.Page[T], error)

Execute returns a pointer of page type with slice of T data

type Query

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

Query struct

func NewCachedQuery

func NewCachedQuery[T any](ctx context.Context, cache *cacheDB.Cache[T], query string, params ...any) (q *Query[T])

NewCachedQuery create a new pointer to Query struct with cache

func NewQuery

func NewQuery[T any](ctx context.Context, query string, params ...any) *Query[T]

NewQuery create a new pointer to Query struct

func (*Query[T]) Many

func (q *Query[T]) Many() ([]T, error)

Many returns a slice of T value

func (*Query[T]) One

func (q *Query[T]) One() (*T, error)

One return a pointer of T value

type Statement

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

Statement struct

func NewStatement

func NewStatement(ctx context.Context, query string, params ...interface{}) *Statement

NewStatement create a new pointer to Statement struct

func (*Statement) Execute

func (s *Statement) Execute() error

Execute apply statement in database

Jump to

Keyboard shortcuts

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