Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsErrNoRows ¶
IsErrNoRows checks if an error is caused by an empty sql result set.
func IsErrUnique ¶
IsErrUnique checks if an error is caused by a unique constraint.
Types ¶
type AddressDao ¶
type AddressDao interface {
// Insert inserts a new address.
Insert(context.Context, Queryer, *models.AddressEntity) error
// Delete deletes an existing address.
Delete(context.Context, Queryer, *models.AddressEntity) error
// FindAll returns all addresses including their domain name.
FindAll(context.Context, Queryer) ([]AddressWithDomain, error)
// FindByMailbox returns all addresses including their domain name by mailbox.
FindByMailbox(context.Context, Queryer, *models.MailboxEntity) ([]AddressWithDomain, error)
}
AddressDao is a data access object for all address related queries.
type AddressWithDomain ¶
type AddressWithDomain struct {
models.AddressEntity
DomainName string `db:"domain_name"`
}
AddressWithDomain is a helper type to eagerly fetch the domain name of an address.
type Conn ¶
Conn is a connection to the sql database.
func OpenConnection ¶
OpenConnection opens an sqlite3 database connection using the configuration from viper.
type DomainDao ¶
type DomainDao interface {
// Insert inserts a new domain.
Insert(context.Context, Queryer, *models.DomainEntity) error
// Update updates an existing domain.
Update(context.Context, Queryer, *models.DomainEntity) error
// Delete deletes an existing domain.
Delete(context.Context, Queryer, *models.DomainEntity) error
// FindAll returns all domains sorted by name.
FindAll(context.Context, Queryer) ([]models.DomainEntity, error)
// FindByName returns the domain matching the name.
FindByName(context.Context, Queryer, string) (*models.DomainEntity, error)
}
DomainDao is a data access object for all domain related queries.
type MailDao ¶
type MailDao interface {
// Insert inserts a new mail.
Insert(context.Context, Queryer, *models.MailEntity) error
// Update updates an existing mail.
Update(context.Context, Queryer, *models.MailEntity) error
// FindByMailbox returns all mails that are not deleted and are "inboxed" to the mailbox.
FindByMailbox(context.Context, Queryer, *models.MailboxEntity) ([]models.MailEntity, error)
// FindDeletable returns all mails which are not yet deleted and are delivered or failed to all
// recipients.
FindDeletable(context.Context, Queryer) ([]models.MailEntity, error)
// FindNextPending returns the next mail with at least one pending recipient.
FindNextPending(context.Context, Queryer) (*models.MailEntity, error)
}
MailDao is a data access object for all mail related queries.
type MailboxCredentialDao ¶
type MailboxCredentialDao interface {
// Upsert inserts new mailbox credentials. When there already is an entry for a mailbox, the
// row will be updated instead.
Upsert(context.Context, Queryer, *models.MailboxCredentialEntity) error
// FindByMailbox returns the credentials associated with a mailbox.
FindByMailbox(context.Context, Queryer, *models.MailboxEntity) (*models.MailboxCredentialEntity, error)
}
MailboxCredentialDao is a data access object for all mailbox-credential related queries.
func NewMailboxCredentialDao ¶
func NewMailboxCredentialDao() MailboxCredentialDao
NewMailboxCredentialDao creates a new MailboxCredentialDao.
type MailboxDao ¶
type MailboxDao interface {
// Insert inserts a new mailbox.
Insert(context.Context, Queryer, *models.MailboxEntity) error
// Update updates an existing mailbox.
Update(context.Context, Queryer, *models.MailboxEntity) error
// DeleteMailbox deletes an existing mailbox.
Delete(context.Context, Queryer, *models.MailboxEntity) error
// FindAll returns all mailboxes.
FindAll(context.Context, Queryer) ([]models.MailboxEntity, error)
// FindByAddress returns the mailbox associated with an address.
FindByAddress(context.Context, Queryer, models.Address) (*models.MailboxEntity, error)
}
MailboxDao is a data access object for all mailbox related queries.
type Queryer ¶
type Queryer interface {
sqlx.ExtContext
}
Queryer is an interface for both transactions and the database connection itself.
type RecipientDao ¶
type RecipientDao interface {
// Insert inserts a new recipient.
Insert(context.Context, Queryer, *models.RecipientEntity) error
// Update updates an existing recipient.
Update(context.Context, Queryer, *models.RecipientEntity) error
// UpdateDelivered updates the status of all recipients matching the mail and mailbox to
// StatusDelivered.
UpdateDelivered(context.Context, Queryer, *models.MailboxEntity, *models.MailEntity) error
// FindPending returns all pending recipients of a mail.
FindPending(context.Context, Queryer, *models.MailEntity) ([]models.RecipientEntity, error)
}
RecipientDao is a data access object for all recipient related queries.
func NewRecipientDao ¶
func NewRecipientDao() RecipientDao
NewRecipientDao creates a new RecipientDao.