Documentation ¶
Index ¶
- Variables
- type Mongo
- func (m *Mongo) AddBook(ctx context.Context, book *models.Book) error
- func (m *Mongo) AddReview(ctx context.Context, review *models.Review) error
- func (m *Mongo) Close(ctx context.Context) (err error)
- func (m *Mongo) GetBook(ctx context.Context, ID string) (*models.Book, error)
- func (m *Mongo) GetBooks(ctx context.Context) (models.Books, error)
- func (m *Mongo) GetReview(ctx context.Context, reviewID string) (*models.Review, error)
- func (m *Mongo) GetReviews(ctx context.Context, bookID string) (models.Reviews, error)
- func (m *Mongo) Init(mongoConfig config.MongoConfig) (err error)
- func (m *Mongo) UpdateReview(ctx context.Context, reviewID string, review *models.Review) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBookNotFound = errors.New("book not found") ErrReviewNotFound = errors.New("review not found") )
Functions ¶
This section is empty.
Types ¶
type Mongo ¶
type Mongo struct { BooksCollection string ReviewsCollection string Database string Session *mgo.Session URI string // contains filtered or unexported fields }
Mongo contains the information needed to create and interact with a mongo session
func (*Mongo) GetBook ¶
GetBook returns a models.Book for a given ID. It returns an error if the Book is not found
func (*Mongo) GetBooks ¶
GetBooks returns all the existing models.Books. It returns an error if the models.Books cannot be listed.
func (*Mongo) GetReview ¶ added in v1.10.0
GetReview returns a models.Review for a given reviewID. It returns an error if the review is not found.
func (*Mongo) GetReviews ¶ added in v1.10.0
GetReviews returns all the existing models.Reviews. It returns an error if the models.Reviews cannot be listed.
Click to show internal directories.
Click to hide internal directories.