Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientRepository ¶
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.
Click to show internal directories.
Click to hide internal directories.