storage

package
v0.0.0-...-303641e Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ErrNotInitialized raised when using a non initialized database
	ErrNotInitialized = Err("db not initialized")

	// ErrInitFailed raised when db cannot be initialized
	ErrInitFailed = Err("db init failed")

	// ErrCreate raised on creation errors
	ErrCreate = Err("creation error")

	// ErrUpdate raised on update errors
	ErrUpdate = Err("update error")

	// ErrDelete raised on delete errors
	ErrDelete = Err("delete error")

	// ErrTransaction raised on transaction errors
	ErrTransaction = Err("transaction error")

	// ErrNotFound raised when a resource is not found
	ErrNotFound = Err("resource not found")

	// ErrUnexpected raised on unexpected errors
	ErrUnexpected = Err("unexpected error")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB using sqlite3 driver

func (*DB) Close

func (s *DB) Close() error

Close the databse

func (*DB) CreateArticle

func (s *DB) CreateArticle(title, body string, author uint) (*model.Article, error)

CreateArticle ...

func (*DB) CreateUser

func (s *DB) CreateUser(username, firstname, lastname string) (*model.User, error)

CreateUser ...

func (*DB) DeleteArticle

func (s *DB) DeleteArticle(id uint) error

DeleteArticle ...

func (*DB) DeleteUser

func (s *DB) DeleteUser(id uint) error

DeleteUser ...

func (*DB) DownVote

func (s *DB) DownVote(user uint, article uint) (*model.Vote, error)

DownVote ...

func (*DB) GetAllArticles

func (s *DB) GetAllArticles() ([]model.Article, error)

GetAllArticles ...

func (*DB) GetAllUsers

func (s *DB) GetAllUsers() ([]model.User, error)

GetAllUsers ...

func (*DB) GetArticleByID

func (s *DB) GetArticleByID(id uint) (*model.Article, error)

GetArticleByID ...

func (*DB) GetArticlesByAuthor

func (s *DB) GetArticlesByAuthor(id uint) ([]model.Article, error)

GetArticlesByAuthor ...

func (*DB) GetUserByID

func (s *DB) GetUserByID(id uint) (*model.User, error)

GetUserByID ...

func (*DB) Open

func (s *DB) Open() error

Open the database

func (*DB) UpVote

func (s *DB) UpVote(user uint, article uint) (*model.Vote, error)

UpVote ...

func (*DB) UpdateArticle

func (s *DB) UpdateArticle(id uint, title *string, body *string) (*model.Article, error)

UpdateArticle ...

func (*DB) UpdateUser

func (s *DB) UpdateUser(id uint, username, firstname, lastname *string) (*model.User, error)

UpdateUser ...

type Err

type Err string

Err type for this package

func (Err) Error

func (e Err) Error() string

Jump to

Keyboard shortcuts

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