sqlite

package
v0.0.0-...-a85e8f0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schema string

embed the sqlite schema within the binary to create the tables at runtime.

Functions

This section is empty.

Types

type DB

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

DB represents the database connection.

func NewDB

func NewDB(dsn string) *DB

NewDB returns a new instance of DB associated with the given datasource name.

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTx starts a transaction and returns a wrapper Tx type. This type provides a reference to the database and a fixed timestamp at the start of the transaction. The timestamp allows us to mock time during tests as well.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection.

func (*DB) Open

func (db *DB) Open() (err error)

Open opens the database connection

type LeaderboardService

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

LeaderboardService represents a service for managing Members.

func NewLeaderboardService

func NewLeaderboardService(db *DB) *LeaderboardService

NewLeaderboardService returns a new instance of MemberService.

func (*LeaderboardService) FindLeaderboard

func (ls *LeaderboardService) FindLeaderboard(date statsd.MonthYear) (*statsd.Leaderboard, error)

FindLeaderboard retrives a Leadboard by its date (year and month). Returns ErrNotFound if no matches are found.

type MemberService

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

MemberService represents a service for managing Members.

func NewMemberService

func NewMemberService(db *DB) *MemberService

NewMemberService returns a new instance of MemberService.

func (*MemberService) CreateMember

func (ms *MemberService) CreateMember(m *statsd.Member) error

CreateMember creates a new Member.

func (*MemberService) DeleteMember

func (ms *MemberService) DeleteMember(id int) error

DeleteMember permanently deletes a Member.

func (*MemberService) FindMember

func (ms *MemberService) FindMember(SlackUID string, date statsd.MonthYear) (*statsd.Member, error)

FindMember retrives a Member by his Slack User ID, the Month, and the Year. Returns ErrNotFound if not matches found.

func (*MemberService) FindMemberByID

func (ms *MemberService) FindMemberByID(id int) (*statsd.Member, error)

FindMemberByID retrieves a Member by ID. Returns ErrNotFound if the ID does not exist.

func (*MemberService) UpdateMember

func (ms *MemberService) UpdateMember(id int, upd statsd.MemberUpdate) (*statsd.Member, error)

UpdateMember updates a Member. Returns ErrNotFound if the member does not exist.

type Tx

type Tx struct {
	*sql.Tx
	// contains filtered or unexported fields
}

Tx wraps the SQL Tx object to provide a timestamp at the start of the transaction.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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