service

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilService = errors.New("service cannot be nil")
)

Functions

This section is empty.

Types

type DefaultService

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

DefaultService is the default service struct

func NewDefaultService

func NewDefaultService(db *sql.DB) (
	instance *DefaultService,
	err error,
)

NewDefaultService creates a new default service

func (*DefaultService) DB

func (d *DefaultService) DB() *sql.DB

DB returns the database

func (*DefaultService) Exec

func (d *DefaultService) Exec(query *string, params ...interface{}) (
	sql.Result,
	error,
)

Exec executes a query with parameters and returns the result

func (*DefaultService) Migrate

func (d *DefaultService) Migrate(queries ...string) error

Migrate migrates the database

func (*DefaultService) QueryRow

func (d *DefaultService) QueryRow(
	query *string,
	params ...interface{},
) *sql.Row

QueryRow runs a query row with parameters and returns the result row

func (*DefaultService) RunTransaction

func (d *DefaultService) RunTransaction(fn func(tx *sql.Tx) error) error

RunTransaction runs a transaction

func (*DefaultService) ScanRow

func (d *DefaultService) ScanRow(
	row *sql.Row,
	destinations ...interface{},
) error

ScanRow scans a row

type Service

type Service interface {
	DB() *sql.DB
	Migrate(queries ...string) error
	RunTransaction(fn func(tx *sql.Tx) error) error
	Exec(query *string, params ...interface{}) (sql.Result, error)
	QueryRow(query *string, params ...interface{}) *sql.Row
	ScanRow(row *sql.Row, destinations ...interface{}) error
}

Service is the interface for the service

Jump to

Keyboard shortcuts

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