stores

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package stores contains different store implementations using MongoDB as storage backend. If multiple storage backends are added, these files could be moved into appropriate packages (mongo, psql etc.) based on the backend they are using.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Posts

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

Posts manages persistence and retrieval of posts.

func NewPosts

func NewPosts(db *mgo.Database) *Posts

NewPosts initializes the Posts store with given mongo db handle.

func (*Posts) Delete

func (posts *Posts) Delete(ctx context.Context, name string) (*domain.Post, error)

Delete removes one post identified by the name.

func (*Posts) Exists

func (posts *Posts) Exists(ctx context.Context, name string) bool

Exists checks if a post exists by name.

func (*Posts) Get

func (posts *Posts) Get(ctx context.Context, name string) (*domain.Post, error)

Get finds a post by name.

func (*Posts) Save

func (posts *Posts) Save(ctx context.Context, post domain.Post) (*domain.Post, error)

Save validates and persists the post.

type Users

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

Users implements UserStore interface.

func NewUsers

func NewUsers(db *mgo.Database) *Users

NewUsers initializes a users store with the given db handle.

func (*Users) Delete

func (users *Users) Delete(ctx context.Context, name string) (*domain.User, error)

Delete removes one user identified by the name.

func (*Users) Exists

func (users *Users) Exists(ctx context.Context, name string) bool

Exists checks if the user identified by the given username already exists. Will return false in case of any error.

func (*Users) FindAll

func (users *Users) FindAll(ctx context.Context, tags []string, limit int) ([]domain.User, error)

FindAll finds all users matching the tags.

func (*Users) FindByName

func (users *Users) FindByName(ctx context.Context, name string) (*domain.User, error)

FindByName finds a user by name. If not found, returns ResourceNotFound error.

func (*Users) Save

func (users *Users) Save(ctx context.Context, user domain.User) (*domain.User, error)

Save validates and persists the user.

Jump to

Keyboard shortcuts

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