database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQuoteNotFound = echo.NewHTTPError(http.StatusNotFound, "quote not found")

Functions

This section is empty.

Types

type Database

type Database interface {
	GetQuotes(pagination Pagination) ([]QuoteEntity, error)
	CountQuotes(text string) (int64, error)
	AddQuote(quote QuoteEntity) (QuoteEntity, error)
	SetQuotes(quotes []QuoteEntity) ([]QuoteEntity, error)
	RandomQuote() (QuoteEntity, error)
}

func GetDatabase added in v1.2.0

func GetDatabase(dsn string) (Database, error)

func NewFileDatabase added in v1.2.0

func NewFileDatabase(dsn string) (Database, error)

func NewMongoDatabase

func NewMongoDatabase(dsn string) (Database, error)

type Pagination

type Pagination struct {
	Page int
	Size int
}

type QuoteEntity

type QuoteEntity struct {
	Id     primitive.ObjectID `bson:"_id" json:"id"`
	Text   string             `bson:"text" json:"text"`
	Source string             `bson:"source" json:"source"`
}

todo make this abstract & split mongo bson in separate struct

Jump to

Keyboard shortcuts

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