database

package
v0.0.0-...-ff919dc Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Client     *mongo.Client
	Collection *mongo.Collection
	DBConfig   *configs.DBConfig
}

Database struct describes the database

func NewDatabase

func NewDatabase(cfg *configs.Config) *Database

NewDatabase returns a new database

func (*Database) CreateQuote

func (d *Database) CreateQuote(ctx context.Context, q *models.Quote) (string, error)

func (*Database) GetAllQuotes

func (d *Database) GetAllQuotes(ctx context.Context, page int) ([]*models.Quote, error)

GetAllQuotes returns all quotes from the database (paginated and batched in options)

func (*Database) GetQuote

func (d *Database) GetQuote(ctx context.Context, objId primitive.ObjectID) (*models.Quote, error)

GetQuote returns a quote from the database

func (*Database) SearchTags

func (d *Database) SearchTags(ctx context.Context, tag string, page int) ([]*models.Quote, error)

SearchTags returns quotes that match a given tag

func (*Database) UpdateQuote

func (d *Database) UpdateQuote(ctx context.Context, q *models.Quote) (int64, error)

Jump to

Keyboard shortcuts

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