mysql

package
v0.0.0-...-8ae76b5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModels

func NewModels(db *sql.DB) interface{}

Types

type AccountModel

type AccountModel struct {
	DB *sql.DB
}

func (*AccountModel) All

func (m *AccountModel) All(userID int64, filters models.Filters) ([]*models.Account, models.Metadata, error)

func (*AccountModel) Insert

func (m *AccountModel) Insert(name string, userID int64, currencyID int64, status string, showInSummary bool) (int64, error)

type AuthSessionModel

type AuthSessionModel struct {
	DB *sql.DB
}

AuthSessionModel represents the MySQL data storage for authentication sessions

func (*AuthSessionModel) Delete

func (m *AuthSessionModel) Delete(id int64) error

Delete removed authentication session by its ID

func (*AuthSessionModel) Get

Get retrieves auth_session record by its ID

func (*AuthSessionModel) GetByToken

func (m *AuthSessionModel) GetByToken(token string) (*models.AuthSession, error)

GetByToken retrieves auth_session record by its token

func (*AuthSessionModel) Insert

func (m *AuthSessionModel) Insert(userID int64, token string) (int64, error)

Insert create a new authentication session

type CategoryModel

type CategoryModel struct {
	DB *sql.DB
}

func (*CategoryModel) All

func (m *CategoryModel) All(userID int64, filters models.Filters) ([]*models.Category, models.Metadata, error)

func (*CategoryModel) Insert

func (m *CategoryModel) Insert(name string, categoryType models.CategoryType, userID int64, inactive bool) (int64, error)

type Models

type Models struct {
	Users UserModel
}

type TransactionModel

type TransactionModel struct {
	DB *sql.DB
}

func (*TransactionModel) All

func (m *TransactionModel) All(userID int64, filters models.Filters) ([]*models.Transaction, models.Metadata, error)

func (*TransactionModel) Insert

func (m *TransactionModel) Insert(amount float64, comment string, userID, categoryID, accountID int64) (int64, error)

type UserModel

type UserModel struct {
	DB *sql.DB
}

UserModel represents the MySQL data storage for users

func (*UserModel) Authenticate

func (m *UserModel) Authenticate(email, password string) (string, error)

Authenticate check the user crendentials and generate auth token

func (*UserModel) Confirm

func (m *UserModel) Confirm(id int64) error

Confirm confirms a not-confirmed user. Returns error if the user does not exists

func (*UserModel) Delete

func (m *UserModel) Delete(id int64) error

Delete removes a user by ID

func (*UserModel) Get

func (m *UserModel) Get(id int64) (*models.User, error)

Get fetches a user by ID. Returns an error if the user not found

func (*UserModel) GetByEmail

func (m *UserModel) GetByEmail(email string) (*models.User, error)

GetByEmail fetches a user by email. Returns a Zero value if the user not found

func (*UserModel) Insert

func (m *UserModel) Insert(email, password string) (int64, error)

Insert creates a not-confirmed user in the database

Jump to

Keyboard shortcuts

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