repositories

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package repositories is a package that contains the repository for the microservice

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DraftMailRepository

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

DraftMailRepository handles database operations related to draft mails

func (*DraftMailRepository) Create

func (r *DraftMailRepository) Create(ctx context.Context, sendMail *models.SendMail) (*models.SendMail, error)

Create creates a new draft mail

func (*DraftMailRepository) Delete

Delete deletes a draft mail by its ID

func (*DraftMailRepository) GetAll

func (r *DraftMailRepository) GetAll(ctx context.Context, userID primitive.ObjectID, page, limit int64) ([]*models.SendMail, int64, error)

GetAll retrieves draft mails for a user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all draft mails and total count.

func (*DraftMailRepository) GetByID

GetByID retrieves a draft mail by its ID

func (*DraftMailRepository) GetSince added in v0.3.0

func (r *DraftMailRepository) GetSince(ctx context.Context, userID primitive.ObjectID, since time.Time, page, limit int64) ([]*models.SendMail, int64, error)

GetSince retrieves draft mails where updated_at is after the specified time for a specific user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all draft mails and total count.

func (*DraftMailRepository) Trash

Trash soft deletes a draft mail by marking it as trashed

func (*DraftMailRepository) Update

Update updates a draft mail by its ID

type DraftMailRepositoryInterface

type DraftMailRepositoryInterface interface {
	// GetAll retrieves draft mails for a user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all draft mails and total count.
	GetAll(ctx context.Context, userID primitive.ObjectID, page, limit int64) ([]*models.SendMail, int64, error)
	GetByID(ctx context.Context, id primitive.ObjectID) (*models.SendMail, error)
	Create(ctx context.Context, sendMail *models.SendMail) (*models.SendMail, error)
	Update(ctx context.Context, id primitive.ObjectID, update bson.M) (*models.SendMail, error)
	Trash(ctx context.Context, id primitive.ObjectID) error
	Delete(ctx context.Context, id primitive.ObjectID) error
	// GetSince retrieves draft mails where updated_at is after the specified time for a specific user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all draft mails and total count.
	GetSince(ctx context.Context, userID primitive.ObjectID, since time.Time, page, limit int64) ([]*models.SendMail, int64, error)
}

DraftMailRepositoryInterface defines the interface for draft mail repository operations

func NewDraftMailRepository

func NewDraftMailRepository(database *mongo.Database) DraftMailRepositoryInterface

NewDraftMailRepository creates a new draft mail repository instance

type FolderRepository

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

FolderRepository handles database operations related to folders

func (*FolderRepository) Create

func (r *FolderRepository) Create(ctx context.Context, folder *models.Folder) (*models.Folder, error)

Create creates a new folder

func (*FolderRepository) Delete

Delete removes a folder

func (*FolderRepository) DeleteByUserID

func (r *FolderRepository) DeleteByUserID(ctx context.Context, userID primitive.ObjectID) error

DeleteByUserID deletes all folders for a specific user

func (*FolderRepository) GetAll

func (r *FolderRepository) GetAll(ctx context.Context, userID primitive.ObjectID) ([]*models.Folder, error)

GetAll retrieves all folders for a user

func (*FolderRepository) GetByID

GetByID retrieves a folder by its ID

func (*FolderRepository) Update

Update modifies an existing folder

type FolderRepositoryInterface

type FolderRepositoryInterface interface {
	GetAll(ctx context.Context, userID primitive.ObjectID) ([]*models.Folder, error)
	Create(ctx context.Context, folder *models.Folder) (*models.Folder, error)
	Update(ctx context.Context, id primitive.ObjectID, folder *models.Folder) (*models.Folder, error)
	Delete(ctx context.Context, id primitive.ObjectID) error
	DeleteByUserID(ctx context.Context, userID primitive.ObjectID) error
}

FolderRepositoryInterface defines the interface for folder repository operations

func NewFolderRepository

func NewFolderRepository(database *mongo.Database) FolderRepositoryInterface

NewFolderRepository creates a new folder repository instance

type MailRepository

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

MailRepository handles database operations related to mails

func (*MailRepository) CleanupTrash

func (r *MailRepository) CleanupTrash(ctx context.Context, userID *primitive.ObjectID, days *int) error

CleanupTrash cleans up trash mails when trashed_at is 30 days or older and trashed is true

func (*MailRepository) Create

func (r *MailRepository) Create(ctx context.Context, mail *models.Mail) (*models.Mail, error)

Create creates a new mail

func (*MailRepository) CreateMany

func (r *MailRepository) CreateMany(ctx context.Context, mails []models.Mail) (bool, error)

CreateMany creates multiple mails

func (*MailRepository) GetAll

func (r *MailRepository) GetAll(ctx context.Context, userID primitive.ObjectID, page, limit int64) ([]*models.Mail, int64, error)

GetAll retrieves mails for a user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all mails and total count.

func (*MailRepository) GetByID

func (r *MailRepository) GetByID(ctx context.Context, id primitive.ObjectID) (*models.Mail, error)

GetByID retrieves a mail by its ID

func (*MailRepository) GetSince added in v0.3.0

func (r *MailRepository) GetSince(ctx context.Context, userID primitive.ObjectID, since time.Time, page, limit int64) ([]*models.Mail, int64, error)

GetSince retrieves mails where updated_at is after the specified time for a specific user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all mails and total count.

func (*MailRepository) Update

func (r *MailRepository) Update(ctx context.Context, mail *models.Mail) error

Update updates a mail object

type MailRepositoryInterface

type MailRepositoryInterface interface {
	// GetAll retrieves mails for a user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all mails and total count.
	GetAll(ctx context.Context, userID primitive.ObjectID, page, limit int64) ([]*models.Mail, int64, error)
	GetByID(ctx context.Context, id primitive.ObjectID) (*models.Mail, error)
	Create(ctx context.Context, mail *models.Mail) (*models.Mail, error)
	CreateMany(ctx context.Context, mails []models.Mail) (bool, error)
	// Update updates a mail object
	Update(ctx context.Context, mail *models.Mail) error
	// CleanupTrash cleans up trash mails
	CleanupTrash(ctx context.Context, userID *primitive.ObjectID, days *int) error
	// GetSince retrieves mails where updated_at is after the specified time for a specific user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all mails and total count.
	GetSince(ctx context.Context, userID primitive.ObjectID, since time.Time, page, limit int64) ([]*models.Mail, int64, error)
}

MailRepositoryInterface defines the interface for mail repository operations

func NewMailRepository

func NewMailRepository(database *mongo.Database) MailRepositoryInterface

NewMailRepository creates a new mail repository instance

type SendMailRepository

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

SendMailRepository handles database operations related to send mails

func (*SendMailRepository) Create

func (r *SendMailRepository) Create(ctx context.Context, sendMail *models.SendMail) (*models.SendMail, error)

Create creates a new send mail

func (*SendMailRepository) Delete

Delete soft deletes a send mail by marking it as trashed

func (*SendMailRepository) GetAll

func (r *SendMailRepository) GetAll(ctx context.Context, userID primitive.ObjectID, page, limit int64) ([]*models.SendMail, int64, error)

GetAll retrieves send mails for a user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all send mails and total count.

func (*SendMailRepository) GetByID

GetByID retrieves a send mail by its ID

func (*SendMailRepository) GetSince added in v0.4.0

func (r *SendMailRepository) GetSince(ctx context.Context, userID primitive.ObjectID, since time.Time, page, limit int64) ([]*models.SendMail, int64, error)

GetSince retrieves send mails where updated_at is after the specified time for a specific user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all send mails and total count.

func (*SendMailRepository) Update

func (r *SendMailRepository) Update(ctx context.Context, id primitive.ObjectID, update bson.M) (*models.SendMail, error)

Update updates a send mail by its ID

type SendMailRepositoryInterface

type SendMailRepositoryInterface interface {
	// GetAll retrieves send mails for a user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all send mails and total count.
	GetAll(ctx context.Context, userID primitive.ObjectID, page, limit int64) ([]*models.SendMail, int64, error)
	GetByID(ctx context.Context, id primitive.ObjectID) (*models.SendMail, error)
	Create(ctx context.Context, sendMail *models.SendMail) (*models.SendMail, error)
	Update(ctx context.Context, id primitive.ObjectID, update bson.M) (*models.SendMail, error)
	Delete(ctx context.Context, id primitive.ObjectID) error
	// GetSince retrieves send mails where updated_at is after the specified time for a specific user. If page and limit are >0, returns paginated results and total count. If page or limit <=0, returns all send mails and total count.
	GetSince(ctx context.Context, userID primitive.ObjectID, since time.Time, page, limit int64) ([]*models.SendMail, int64, error)
}

SendMailRepositoryInterface defines the interface for send mail repository operations

func NewSendMailRepository

func NewSendMailRepository(database *mongo.Database) SendMailRepositoryInterface

NewSendMailRepository creates a new send mail repository instance

type TagRepository

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

TagRepository handles database operations related to tags

func NewTagRepository

func NewTagRepository(db *mongo.Database) *TagRepository

NewTagRepository creates a new tag repository instance

func (*TagRepository) Create

func (r *TagRepository) Create(ctx context.Context, tag *models.Tag) (*models.Tag, error)

Create adds a new tag to the database

func (*TagRepository) Delete

func (r *TagRepository) Delete(ctx context.Context, id primitive.ObjectID) error

Delete removes a tag from the database

func (*TagRepository) DeleteByUserID

func (r *TagRepository) DeleteByUserID(ctx context.Context, userID primitive.ObjectID) error

DeleteByUserID deletes all tags for a specific user

func (*TagRepository) GetAll

func (r *TagRepository) GetAll(ctx context.Context, userID *primitive.ObjectID) ([]*models.Tag, error)

GetAll retrieves all tags with optional user filtering

func (*TagRepository) GetByID

func (r *TagRepository) GetByID(ctx context.Context, id primitive.ObjectID) (*models.Tag, error)

GetByID retrieves a tag by its ID

func (*TagRepository) Update

func (r *TagRepository) Update(ctx context.Context, tag *models.Tag) (*models.Tag, error)

Update modifies an existing tag in the database

type TagRepositoryInterface

type TagRepositoryInterface interface {
	GetAll(ctx context.Context, userID *primitive.ObjectID) ([]*models.Tag, error)
	GetByID(ctx context.Context, id primitive.ObjectID) (*models.Tag, error)
	Create(ctx context.Context, tag *models.Tag) (*models.Tag, error)
	Update(ctx context.Context, tag *models.Tag) (*models.Tag, error)
	Delete(ctx context.Context, id primitive.ObjectID) error
	DeleteByUserID(ctx context.Context, userID primitive.ObjectID) error
}

TagRepositoryInterface defines the interface for tag repository operations

Jump to

Keyboard shortcuts

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