mongo

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option is a Store option.

func Collection

func Collection(name string) Option

Collection returns an Option that specifies the used collection.

func CreateIndexes

func CreateIndexes(ci bool) Option

CreateIndexes returns an Option that creates the indexes for the mails collection.

func Database

func Database(name string) Option

Database returns an Option that specifies the used database.

func WithoutAttachmentContent added in v0.10.0

func WithoutAttachmentContent(ac bool) Option

WithoutAttachmentContent returns an Option that empties the attachment contents of mails before they are stored in the database.

type Store

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

Store is the mongo store.

func NewStore

func NewStore(ctx context.Context, client *mongo.Client, opts ...Option) (*Store, error)

NewStore returns a mongo store. It returns an error if either client is nil or CreateIndexes() is used and index creation fails.

func (*Store) Find

func (s *Store) Find(ctx context.Context, id uuid.UUID) (archive.Mail, error)

Find fetches the mail with the given id from the database. If it can't find the mail, it returns archive.ErrNotFound.

func (*Store) Insert

func (s *Store) Insert(ctx context.Context, m archive.Mail) error

Insert stores m into the database. If there's already a stored mail with the same ID as m, m will override the previously stored mail.

func (*Store) Query

func (s *Store) Query(ctx context.Context, q query.Query) (archive.Cursor, error)

Query queries the database for mails matching the query q.

func (*Store) Remove

func (s *Store) Remove(ctx context.Context, m archive.Mail) error

Remove deletes the mail m from the database.

Jump to

Keyboard shortcuts

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