storage

package
v0.0.0-...-ae8581d Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

Storage is an interface for interacting with a storage layer

func New

func New(db *sql.DB) *Storage

New returns a new TopicalStore

func (*Storage) CreateMessage

func (s *Storage) CreateMessage(m *models.Message) (*models.Message, error)

CreateMessage inserts a message into the DB

func (*Storage) CreateTopic

func (s *Storage) CreateTopic(title string) (*models.Topic, error)

CreateTopic inserts a new topic into the DB

func (*Storage) GetRecentTopics

func (s *Storage) GetRecentTopics() ([]models.Topic, error)

GetRecentTopics returns a list of the 50 most recently posted-on topics

func (*Storage) GetTopic

func (s *Storage) GetTopic(id int) (*models.Topic, error)

GetTopic retrieves a topic from DB by topic

type TopicalStore

type TopicalStore interface {
	GetTopic(id int) (*models.Topic, error)
	GetRecentTopics() ([]models.Topic, error)
	CreateMessage(m *models.Message) (*models.Message, error)
	CreateTopic(title string) (*models.Topic, error)
}

TopicalStore implements an CRUD action interface for topics/messages

Jump to

Keyboard shortcuts

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