mysql

package
v0.0.0-...-96db308 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TodoModel

type TodoModel struct {
	DB *sql.DB
}

TodoModel type which wraps a sql.DB connection pool.

func (*TodoModel) Delete

func (m *TodoModel) Delete(id int) error

Delete will delete a specific todo based on its id.

func (*TodoModel) Get

func (m *TodoModel) Get(id int) (*models.Todo, error)

Get will return a specific todo based on its id.

func (*TodoModel) Insert

func (m *TodoModel) Insert(title, content string, userID int) (int, error)

Insert a new todo into the database.

func (*TodoModel) Latest

func (m *TodoModel) Latest(userID int) ([]*models.Todo, error)

Latest will return the 10 most recently created todos.

func (*TodoModel) Update

func (m *TodoModel) Update(id int, title, content string, completed bool) error

Update will update a specific todo based on its id.

type UserModel

type UserModel struct {
	DB *sql.DB
}

UserModel is used to interact with our datastore

func (*UserModel) Authenticate

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

Authenticate method to verify whether a user exists with the provided email address and password. This will return the relevant user ID if they do.

func (*UserModel) Get

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

Get method to fetch details for a specific user based on their user ID.

func (*UserModel) Insert

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

Insert method to add a new record to the users table.

Jump to

Keyboard shortcuts

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