mongo

package
v0.0.0-...-f54b72f Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PhotoRepository

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

func NewPhotoRepository

func NewPhotoRepository(client *mongo.Client, config *config.MongoConfig) *PhotoRepository

NewPhotoRepository creates a new instance of the PhotoRepository struct with the provided MongoDB client and configuration.

Parameters: - client: A pointer to a mongo.Client object representing the MongoDB client. - config: A pointer to a config.MongoConfig object representing the MongoDB configuration.

Returns: - A pointer to a PhotoRepository object representing the newly created repository.

func (*PhotoRepository) Create

func (p *PhotoRepository) Create(ctx context.Context, photo *domain.Photo) error

Create inserts a new photo document into the MongoDB collection.

Parameters: - ctx: The context.Context object for the function. - photo: A pointer to a domain.Photo object representing the photo to be inserted.

Returns: - error: An error object if there was an error inserting the photo, otherwise nil.

func (*PhotoRepository) Delete

func (p *PhotoRepository) Delete(ctx context.Context, id string) error

Delete deletes a photo document from the MongoDB collection by its ID.

Parameters: - ctx: The context.Context object for the function. - id: The ID of the photo to be deleted.

Returns: - error: An error object if there was an error deleting the photo, otherwise nil.

func (*PhotoRepository) FindAll

func (p *PhotoRepository) FindAll(ctx context.Context) ([]domain.Photo, error)

FindAll finds all photo documents in the MongoDB collection.

Parameters: - ctx: The context.Context object for the function.

Returns: - photos: A slice of domain.Photo objects representing all the found photos. - error: An error object if there was an error finding the photos, otherwise nil.

func (*PhotoRepository) FindByID

func (p *PhotoRepository) FindByID(ctx context.Context, id string) (*domain.Photo, error)

FindByID finds a photo document in the MongoDB collection by its ID.

Parameters: - ctx: The context.Context object for the function. - id: The ID of the photo to be found.

Returns: - photo: A pointer to a domain.Photo object representing the found photo, or nil if not found. - error: An error object if there was an error finding the photo, otherwise nil.

func (*PhotoRepository) Update

func (p *PhotoRepository) Update(ctx context.Context, photo *domain.Photo) error

Update updates a photo document in the MongoDB collection.

Parameters: - ctx: The context.Context object for the function. - photo: A pointer to a domain.Photo object representing the photo to be updated.

Returns: - error: An error object if there was an error updating the photo, otherwise nil.

Jump to

Keyboard shortcuts

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