Documentation ¶
Overview ¶
Package mongo provides a MongoDB database repository implementation.
Index ¶
- func NewMongoDB(ctx context.Context, config Config) (*mongo.Database, error)
- type Config
- type NoteRepository
- func (r NoteRepository) DeleteOne(ctx context.Context, noteID string) error
- func (r NoteRepository) FindMany(ctx context.Context, userID string) ([]domain.Note, error)
- func (r NoteRepository) FindManyAsync(ctx context.Context, userID string) (<-chan domain.Note, <-chan error)
- func (r NoteRepository) FindOne(ctx context.Context, noteID string) (domain.Note, error)
- func (r NoteRepository) SaveOne(ctx context.Context, note domain.Note) error
- func (r NoteRepository) UpdateOne(ctx context.Context, note domain.Note) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Host string // Host specifies the MongoDB server host. Port string // Port specifies the MongoDB server port. Username string // Username specifies the username used to authenticate with the MongoDB server. Password string // Password specifies the password used to authenticate with the MongoDB server. Database string // Database specifies the name of the MongoDB database to use. }
Config represents MongoDB configuration.
type NoteRepository ¶
type NoteRepository struct {
// contains filtered or unexported fields
}
NoteRepository is a struct that provides methods for interacting with the MongoDB database.
func NewNoteRepository ¶
func NewNoteRepository(db *mongo.Database, collection ...string) (*NoteRepository, error)
NewNoteRepository creates a new NoteRepository instance with a MongoDB collection.
func (NoteRepository) DeleteOne ¶
func (r NoteRepository) DeleteOne(ctx context.Context, noteID string) error
DeleteOne deletes a note from the MongoDB collection. If no note with the specified ID is found, returns an error.
func (NoteRepository) FindMany ¶
FindMany finds all notes associated with a specific user in the MongoDB collection. If no notes are found, returns an error.
func (NoteRepository) FindManyAsync ¶
func (NoteRepository) FindOne ¶
FindOne finds a note with a specific ID in the MongoDB collection. If no note is found, returns an error.
Click to show internal directories.
Click to hide internal directories.