repository

package
v0.0.0-...-4f6455c Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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

func NewMongoDB

func NewMongoDB(ctx context.Context, cfg Config) (*mongo.Client, error)

NewMongoDB - open connect and ping trying

Types

type Config

type Config struct {
	Username, Password, Url string
}

Config - db

type Product

type Product struct {
	// contains filtered or unexported fields
}

Product

func NewProduct

func NewProduct(products *mongo.Collection) *Product

NewProduct - constructor

func (*Product) DeleteMany

func (r *Product) DeleteMany(ctx context.Context, filter primitive.M) error

func (*Product) FindOneByName

func (r *Product) FindOneByName(ctx context.Context, name string) (domain.Product, error)

FindOneByName

func (*Product) GetProducts

func (r *Product) GetProducts(ctx context.Context, req *pb.GetProductsRequest) ([]*pb.Product, error)

GetProducts

func (*Product) SaveOrUpdate

func (r *Product) SaveOrUpdate(ctx context.Context, products []domain.Product) error

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

type Repository

type Repository struct {
	Producter
}

Repository

func NewRepository

func NewRepository(db *mongo.Client) *Repository

NewRepository

Jump to

Keyboard shortcuts

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