storage

package
v0.0.0-...-a3ada0b Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

MongoDB client structure

func NewClient

func NewClient(cfg *config.Client) (*Client, error)

Create new client. Connect to DB via URI and set collection and context

func (*Client) AddTransaction

func (c *Client) AddTransaction(chatID int, amount float64, category string, kind string) error

Add expense or income transaction

func (*Client) CreateUserDocument

func (c *Client) CreateUserDocument(chatID int) error

Create user document if it doesn't exist

func (*Client) DeleteTransaction

func (c *Client) DeleteTransaction(chatID int, transactionNumber string, kind string) error

Delete expense or income transaction

func (*Client) GetTransactions

func (c *Client) GetTransactions(chatID int) ([]Transaction, []Transaction)

Get user's expenses and income transactions

type Transaction

type Transaction struct {
	Category     string    `bson:"category"`
	Amount       float64   `bson:"amount"`
	CreationDate time.Time `bson:"creationDate"`
}

Expense or income transaction structure

Jump to

Keyboard shortcuts

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