storage

package
v0.0.0-...-2731c89 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoSuchSnippetErr = errors.New("no such snippet")
	NoSuchCommentErr = errors.New("no such comment")
	InvalidVoteErr   = errors.New("invalid vote")
)

Functions

This section is empty.

Types

type Memory

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

func NewMemory

func NewMemory() *Memory

func (*Memory) AddComment

func (m *Memory) AddComment(comment types.Comment) (types.CommentId, error)

func (*Memory) AddSnippet

func (m *Memory) AddSnippet(snippet types.Snippet) (types.SnippetId, error)

func (*Memory) CreateAccount

func (m *Memory) CreateAccount(cred auth.Credentials) (auth.Account, error)

func (*Memory) DeleteComment

func (m *Memory) DeleteComment(comment types.CommentId) error

func (*Memory) DeleteSnippet

func (m *Memory) DeleteSnippet(snippet types.SnippetId) error

func (*Memory) GetAccountById

func (m *Memory) GetAccountById(id uint) (auth.Account, error)

func (*Memory) GetAccountByUsername

func (m *Memory) GetAccountByUsername(username string) (auth.Account, error)

func (*Memory) GetComment

func (m *Memory) GetComment(comment types.CommentId) (types.Comment, error)

func (*Memory) GetComments

func (m *Memory) GetComments(snippet types.SnippetId) ([]types.Comment, error)

func (*Memory) GetSnippet

func (m *Memory) GetSnippet(snippet types.SnippetId) (types.Snippet, error)

func (*Memory) GetSnippetsByLanguage

func (m *Memory) GetSnippetsByLanguage(language types.ProgrammingLanguage) ([]types.Snippet, error)

func (*Memory) GetSnippetsByUser

func (m *Memory) GetSnippetsByUser(user types.UserId) ([]types.Snippet, error)

func (*Memory) GetVote

func (m *Memory) GetVote(user types.UserId, snippet types.SnippetId) (int, error)

func (*Memory) Vote

func (m *Memory) Vote(user types.UserId, snippet types.SnippetId, vote int) error

type Postgres

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

func NewPostgres

func NewPostgres(connStr string) (Postgres, error)

func (Postgres) AddComment

func (p Postgres) AddComment(comment types.Comment) (types.CommentId, error)

func (Postgres) AddSnippet

func (p Postgres) AddSnippet(snippet types.Snippet) (types.SnippetId, error)

func (Postgres) Close

func (p Postgres) Close() error

func (Postgres) CreateAccount

func (p Postgres) CreateAccount(cred auth.Credentials) (auth.Account, error)

func (Postgres) DeleteComment

func (p Postgres) DeleteComment(comment types.CommentId) error

func (Postgres) DeleteSnippet

func (p Postgres) DeleteSnippet(snippet types.SnippetId) error

func (Postgres) GetAccountById

func (p Postgres) GetAccountById(id uint) (auth.Account, error)

func (Postgres) GetAccountByUsername

func (p Postgres) GetAccountByUsername(username string) (auth.Account, error)

func (Postgres) GetComment

func (p Postgres) GetComment(comment types.CommentId) (types.Comment, error)

func (Postgres) GetComments

func (p Postgres) GetComments(snippet types.SnippetId) ([]types.Comment, error)

func (Postgres) GetSnippet

func (p Postgres) GetSnippet(snippet types.SnippetId) (types.Snippet, error)

func (Postgres) GetSnippetsByLanguage

func (p Postgres) GetSnippetsByLanguage(language types.ProgrammingLanguage) ([]types.Snippet, error)

func (Postgres) GetSnippetsByUser

func (p Postgres) GetSnippetsByUser(user types.UserId) ([]types.Snippet, error)

func (Postgres) GetVote

func (p Postgres) GetVote(user types.UserId, snippet types.SnippetId) (int, error)

func (Postgres) SetSnippetHighlight

func (p Postgres) SetSnippetHighlight(snippet types.SnippetId, highlight string) error

func (Postgres) Vote

func (p Postgres) Vote(user types.UserId, snippet types.SnippetId, vote int) error

type SnippetVote

type SnippetVote struct {
	UserId    types.UserId
	SnippetId types.SnippetId
	Vote      int
}

Jump to

Keyboard shortcuts

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