Documentation ¶
Index ¶
- Constants
- func NewMongoDB(ctx context.Context, cfg Config) (*mongo.Client, error)
- type Config
- type Product
- func (r *Product) DeleteMany(ctx context.Context, filter primitive.M) error
- func (r *Product) FindOneByName(ctx context.Context, name string) (domain.Product, error)
- func (r *Product) GetProducts(ctx context.Context, req *pb.GetProductsRequest) ([]*pb.Product, error)
- func (r *Product) SaveOrUpdate(ctx context.Context, products []domain.Product) error
- type Producter
- type Repository
Constants ¶
View Source
const ( DEFAULT_PRICE_CHANGE_COUNT = 1 IS_UPDATED_FLAG = true )
View Source
const DB_NAME = "store"
View Source
const PRODUCT_COLLECTION_NAME = "product"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Product ¶
type Product struct {
// contains filtered or unexported fields
}
Product
func (*Product) DeleteMany ¶
func (*Product) FindOneByName ¶
FindOneByName
func (*Product) GetProducts ¶
func (r *Product) GetProducts(ctx context.Context, req *pb.GetProductsRequest) ([]*pb.Product, error)
GetProducts
func (*Product) SaveOrUpdate ¶
TODO Need to refactor this method - it is too big and does a lot. Break it down into simple methods (insert, update, delete) with the database and move the business logic to the services layer. SaveOrUpdate
type Producter ¶
type Producter interface { SaveOrUpdate(ctx context.Context, products []domain.Product) error GetProducts(ctx context.Context, req *pb.GetProductsRequest) ([]*pb.Product, error) }
Producter
Click to show internal directories.
Click to hide internal directories.