db

package
v0.0.0-...-7e22837 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRecord = fmt.Errorf("no matching record found")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     int
	Username string
	Password string
	DbName   string
	Logger   zerolog.Logger
}

type Database

type Database struct {
	Conn   *sql.DB
	Logger zerolog.Logger
}

func Init

func Init(cfg Config) (Database, error)

func (Database) DeletePost

func (db Database) DeletePost(postId int) error

func (Database) GetPostById

func (db Database) GetPostById(postId int) (models.Post, error)

func (Database) GetPosts

func (db Database) GetPosts() ([]models.Post, error)

func (Database) SavePost

func (db Database) SavePost(post *models.Post) error

func (Database) UpdatePost

func (db Database) UpdatePost(postId int, post models.Post) error

Jump to

Keyboard shortcuts

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