provider

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionDetails

type ConnectionDetails struct {
	Host     string
	Port     string
	User     string
	Password string
	Database string
}

type Postgre

type Postgre struct {
	Database *sql.DB
	ConnectionDetails
}

Postgre is a provider that uses PostgreSQL as the underlying database.

func (*Postgre) Balance

func (p *Postgre) Balance(XUID string) (uint64, error)

Balance ...

func (*Postgre) Close

func (p *Postgre) Close() error

Close closes the opened database connection and saves the sqlite file.

func (*Postgre) Decrease added in v0.0.6

func (p *Postgre) Decrease(XUID string, value uint64) error

Decrease ...

func (*Postgre) Increase

func (p *Postgre) Increase(XUID string, value uint64) error

Increase ...

func (*Postgre) Set

func (p *Postgre) Set(XUID string, value uint64) error

Set ...

type Provider

type Provider interface {
	Balance(XUID string) (uint64, error)

	Set(XUID string, value uint64) error

	Decrease(XUID string, value uint64) error

	Increase(XUID string, value uint64) error

	Close() error
}

Provider is an interface that defines the methods that a provider must implement.

type SQLite

type SQLite struct {
	Database *sql.DB
}

SQLite is a provider that uses SQLite as the underlying database.

func NewPostgre

func NewPostgre(c ConnectionDetails) (*SQLite, error)

NewPostgre creates a new Postgre provider and opens the database. If the economy database does not exist, it will be created.

func NewSQLite

func NewSQLite(path string) (*SQLite, error)

NewSQLite creates a new SQLite provider and opens the database. If the economy database does not exist, it will be created.

func (*SQLite) Balance

func (S *SQLite) Balance(XUID string) (uint64, error)

Balance ...

func (*SQLite) Close

func (S *SQLite) Close() error

Close closes the opened database connection and saves the sqlite file.

func (*SQLite) Decrease added in v0.0.6

func (S *SQLite) Decrease(XUID string, value uint64) error

Decrease ...

func (*SQLite) Increase

func (S *SQLite) Increase(XUID string, value uint64) error

Increase ...

func (*SQLite) Set

func (S *SQLite) Set(XUID string, value uint64) error

Set ...

Jump to

Keyboard shortcuts

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