sqlstore

package
v0.0.0-...-baeefe5 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostTable    = "posts"
	CommentTable = "comments"
)

Variables

This section is empty.

Functions

func CreateTables

func CreateTables(db *sqlx.DB)

func DropTables

func DropTables(db *sqlx.DB)

func FindCommentsByPostID

func FindCommentsByPostID(ctx context.Context, db SqlxDatabase, postID int) ([]*models.Comment, error)

func FindPostByID

func FindPostByID(ctx context.Context, db SqlxDatabase, id int) (*models.Post, error)

func SaveComment

func SaveComment(ctx context.Context, db SqlxDatabase, c *models.Comment) error

func SavePost

func SavePost(ctx context.Context, db SqlxDatabase, p *models.Post) error

Types

type SqlxDatabase

type SqlxDatabase interface {
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

Jump to

Keyboard shortcuts

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