repository

package
v0.0.0-...-df1b72c Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Holding

type Holding struct {
	ID            int64     `json:"id"`
	Amount        int       `json:"amount"`
	PurchaseDate  time.Time `json:"purchase_date"`
	PurchasePrice int       `json:"purchase_price"`
}

type Repository

type Repository interface {
	Migrate() error //To create or load an existent database
	InsertHolding(h Holding) (*Holding, error)
	AllHoldings() ([]Holding, error)
	GetHoldingByID(id int) (*Holding, error)
	UpdateHolding(id int64, updated Holding) error
	DeleteHolding(id int64) error
}

type SQLiteRepository

type SQLiteRepository struct {
	Repository
	Conn *sql.DB
}

func NewSQLiteRespository

func NewSQLiteRespository(db *sql.DB) *SQLiteRepository

func (*SQLiteRepository) AllHoldings

func (r *SQLiteRepository) AllHoldings() ([]Holding, error)

func (*SQLiteRepository) DeleteHolding

func (r *SQLiteRepository) DeleteHolding(id int64) error

func (*SQLiteRepository) GetHoldingByID

func (r *SQLiteRepository) GetHoldingByID(id int) (*Holding, error)

func (*SQLiteRepository) InsertHolding

func (r *SQLiteRepository) InsertHolding(h Holding) (*Holding, error)

func (*SQLiteRepository) Migrate

func (r *SQLiteRepository) Migrate() error

func (*SQLiteRepository) UpdateHolding

func (r *SQLiteRepository) UpdateHolding(id int64, updated Holding) error

Jump to

Keyboard shortcuts

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