services

package
v0.0.0-...-f0a4b7f Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SnippetsService

type SnippetsService struct {
	DB *sql.DB
}

SnippetsService wraps a sql.DB connection pool.

func (*SnippetsService) Get

func (m *SnippetsService) Get(id int) (models.Snippet, error)

Get will return a specific snippet based on its id.

func (*SnippetsService) Insert

func (m *SnippetsService) Insert(title string, content string, expires int) (int, error)

Insert will insert a new snippet into the database.

func (*SnippetsService) Latest

func (m *SnippetsService) Latest() ([]models.Snippet, error)

Latest will return the 10 most recently created snippets.

type UsersService

type UsersService struct {
	DB *sql.DB
}

UsersService wraps a sql.DB connection pool.

func (*UsersService) Authenticate

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

Authenticate verifies a user's email and password. It returns the user's ID if authentication is successful, or an error if it fails.

func (*UsersService) Exists

func (m *UsersService) Exists(id int) (bool, error)

Exists checks if a user with the given ID exists in the database. It returns true if the user exists, or false otherwise.

func (*UsersService) Insert

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

Insert adds a new user to the database with the provided name, email, and password. It returns an error if the insertion fails or if the email is already in use.

Jump to

Keyboard shortcuts

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