home

package
v0.0.0-...-f12052e Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Collection is a name of the MongoDB collection for homes.
	Collection = "homes"

	// Bucket for storing photos.
	Bucket = "photos"
)

Variables

View Source
var (
	ErrIDNotFound = errors.New("home id does not exist")
	ErrIDNotEmpty = errors.New("home id must be empty")
)

Functions

This section is empty.

Types

type Home

type Home interface {
	Set(ctx context.Context, home *model.Home, photos []model.Photo) error
	Get(ctx context.Context, id string) (model.Home, error)
}

Home stores the home model into the database and minio. we use minio for storing the image files of each home.

type MongoHome

type MongoHome struct {
	DB     *mongo.Database
	Minio  *minio.Client
	Tracer trace.Tracer
}

MongoURL communicate with homes collection in MongoDB.

func NewMongoHome

func NewMongoHome(db *mongo.Database, client *minio.Client, tracer trace.Tracer) *MongoHome

NewMongoHome creates new Home store.

func (*MongoHome) Get

func (s *MongoHome) Get(ctx context.Context, id string) (model.Home, error)

Get retrieves home of the given id if it exists.

func (*MongoHome) Set

func (s *MongoHome) Set(ctx context.Context, home *model.Home, photos []model.Photo) error

Set saves given home in database and returns its id.

Jump to

Keyboard shortcuts

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