Documentation ¶
Index ¶
- type PhotoRepository
- func (p *PhotoRepository) Create(ctx context.Context, photo *domain.Photo) error
- func (p *PhotoRepository) Delete(ctx context.Context, id string) error
- func (p *PhotoRepository) FindAll(ctx context.Context) ([]domain.Photo, error)
- func (p *PhotoRepository) FindByID(ctx context.Context, id string) (*domain.Photo, error)
- func (p *PhotoRepository) Update(ctx context.Context, photo *domain.Photo) error
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 ¶
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 ¶
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 ¶
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 ¶
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.