repository

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRows no result found.
	ErrNoRows = errors.New("repository fakesql: no rows found")
	// ErrConnectTimeout simulates timeout to db call.
	ErrConnectTimeout = errors.New("repository fakesql: context deadline exceeded")
)

Functions

This section is empty.

Types

type DummyDB

type DummyDB struct {
}

DummyDB as a buggy *sql.DB.

func (*DummyDB) Ping

func (db *DummyDB) Ping(_ context.Context) error

Ping sql.DB impl.

func (*DummyDB) QueryRowCtx

func (db *DummyDB) QueryRowCtx(_ context.Context, _ string) (int, error)

QueryRowCtx sql.DB impl.

func (*DummyDB) QueryRowsCtx

func (db *DummyDB) QueryRowsCtx(_ context.Context, _ string) error

QueryRowsCtx sql.DB impl.

type UserRepository

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

UserRepository is dummy user repo. In reality, YOU SHOULD PREFER USING SQLC-GGENERATED CODE.

func NewUserRepository

func NewUserRepository(db *DummyDB) *UserRepository

NewUserRepository returns user repo with dummy db.

func (*UserRepository) CreateUser

func (r *UserRepository) CreateUser(ctx context.Context, u *user.User) error

CreateUser insert new user to db.

func (*UserRepository) FindUserByID

func (r *UserRepository) FindUserByID(ctx context.Context, id int) (*user.User, error)

FindUserByID finds user by specific ID inside db.

Jump to

Keyboard shortcuts

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