Documentation ¶
Overview ¶
Copyright (c) 2023 Tiago Melo. All rights reserved. Use of this source code is governed by the MIT License that can be found in the LICENSE file.
Package product provides the business logic and data operations for the product catalog. It includes functions for creating, getting, updating, deleting, and listing products.
Index ¶
- func Create(ctx context.Context, db *store.MongoDb, newProduct *models.Product) (*models.Product, error)
- func Delete(ctx context.Context, db *store.MongoDb, ...) (*productcatalog.DeleteProductResponse, error)
- func Get(ctx context.Context, db *store.MongoDb, req *productcatalog.GetProductRequest) (*models.Product, error)
- func List(ctx context.Context, db *store.MongoDb, ...) ([]*models.Product, error)
- func Update(ctx context.Context, db *store.MongoDb, productToUpdate *models.Product) (*models.Product, error)
- type Cursor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(ctx context.Context, db *store.MongoDb, newProduct *models.Product) (*models.Product, error)
Create creates a new product in the database.
func Delete ¶
func Delete(ctx context.Context, db *store.MongoDb, req *productcatalog.DeleteProductRequest) (*productcatalog.DeleteProductResponse, error)
Delete deletes a product from the database by uuid.
func Get ¶
func Get(ctx context.Context, db *store.MongoDb, req *productcatalog.GetProductRequest) (*models.Product, error)
Get retrieves a product from the database by uuid.
Types ¶
type Cursor ¶
type Cursor interface { Decode(interface{}) error Err() error Close(context.Context) error Next(context.Context) bool }
Cursor is an interface that defines the methods necessary for iterating over query results in a data layer. This interface is particularly useful for simplifying unit tests by allowing the implementation of mock cursors that can be used for testing data retrieval and manipulation operations.