mongostore

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package mongostore provides the mongodb store implementation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Provider is the store provider name.
	Provider = "mongo"
)

Functions

This section is empty.

Types

type Config

type Config struct {
	DatabaseName   string
	CollectionName string
	CreateIndexes  bool
}

Config is the store configuration.

type Option

type Option func(*Config)

Option is a store option.

func Collection

func Collection(name string) Option

Collection configures the used collection. Defaults to "letters".

func CreateIndexes

func CreateIndexes(create bool) Option

CreateIndexes configures the store to create the indexes for the fields of the letters. By default, this option is set to true.

func Database

func Database(name string) Option

Database configures the used database. Defaults to "postdog".

type Store

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

Store is the mongodb store.

func New

func New(client *mongo.Client, opts ...Option) (*Store, error)

New creates a mongodb store. By default, the store uses the "postdog" database and "letters" collection. You can configure the store with opts.

func (*Store) Config

func (s *Store) Config() Config

Config returns the store configuration.

func (*Store) Get added in v0.5.0

func (s *Store) Get(ctx context.Context, id uuid.UUID) (store.Letter, error)

Get retrieves the letter with the given id

func (*Store) Insert

func (s *Store) Insert(ctx context.Context, let store.Letter) error

Insert inserts let into s.

func (*Store) Query

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

Query queries the store for letters, filtered and sorted by q.

Jump to

Keyboard shortcuts

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