repository

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientRepository

type ClientRepository interface {
	GetAuthor(id string) (data.Author, error)
}

func NewClientRepository

func NewClientRepository(clientInfo mgrpc.ClientInfo) (ClientRepository, error)

NewClientRepository creates a new client repository.

func NewFakeClientRepository added in v0.2.0

func NewFakeClientRepository() ClientRepository

type Database

type Database interface {
	// AddQuote adds a new quote to the database.
	AddQuote(quote data.Quote) (string, error)

	// ListAll returns all quotes in the database.
	ListAll() []data.Quote

	// UpdateQuote updates a quote in the database.
	UpdateQuote(quote data.Quote) (data.Quote, error)

	// DeleteQuote deletes a quote from the database.
	DeleteQuote(id string) error

	// GetQuote returns a quote from the database.
	GetQuote(id string) (data.Quote, error)

	// GetAuthorQuotes returns all quotes from an author.
	GetAuthorQuotes(authorID string) []data.Quote

	// DeleteAuthorQuotes deletes all quotes from an author.
	DeleteAuthorQuotes(authorID string) error

	// GetRandomQuote returns a random quote from the database.
	GetRandomQuote() (data.Quote, error)
}

Database represents the databaseName interface.

func NewInMemoryDatabase added in v0.2.0

func NewInMemoryDatabase() Database

func NewMongoDatabase

func NewMongoDatabase(connection *mdb.MongoConnection) Database

NewMongoDatabase creates a new mongo database.

type Repository

type Repository interface {
	// AddQuote adds a new quote to the database.
	AddQuote(quote data.Quote) (string, error)

	// ListAll returns all quotes in the database.
	ListAll() []data.Quote

	// UpdateQuote updates a quote in the database.
	UpdateQuote(quote data.Quote) (data.Quote, error)

	// DeleteQuote deletes a quote from the database.
	DeleteQuote(id string) error

	// GetQuote returns a quote from the database.
	GetQuote(id string) (data.Quote, error)

	// GetAuthorQuotes returns all quotes from an author.
	GetAuthorQuotes(authorID string) []data.Quote

	// DeleteAuthorQuotes deletes all quotes from an author.
	DeleteAuthorQuotes(authorID string) error

	// GetRandomQuote returns a random quote from the database.
	GetRandomQuote() (data.Quote, error)
}

Repository represents the repository interface.

func New

func New(db Database, clientRepository ClientRepository) Repository

New creates a new repository.

Jump to

Keyboard shortcuts

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