mongo

package
v0.0.0-...-89bf0d2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(mongoURI string) (stores.Interface, error)

New initializes a new Store with MongoDB as storage backend.

Types

type Store

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

Store is the implementation `stores.Interface` using MongoDB as the storage backend.

func (*Store) Create

func (ms *Store) Create(obj *usher.Object) *usher.Error

Create stores the object into the storage backend. If object with same ID already exists, a '409 Conflict' error is returned.

func (*Store) Delete

func (ms *Store) Delete(obj *usher.Object, id usher.ObjectID) *usher.Error

Delete will delete the object identified by (name, kind, parent). If item does not exist matching the given query, '404 NotFound' will be returned.

func (*Store) Exists

func (ms *Store) Exists(id usher.ObjectID) *usher.Error

Exists checks if an object exists which matches the given query.

func (*Store) Get

func (ms *Store) Get(obj *usher.Object, id usher.ObjectID) *usher.Error

Get an object matching all query clauses.

func (*Store) GetAll

func (ms *Store) GetAll(objList *[]usher.Object, kind string, qa ...interface{}) *usher.Error

GetAll will fetch all the objects of the given 'kind'. Also, additional queries can be provided as variadic arguments. If no item found matching the (kind, query), the pointer 'obj' to list will be left empty.

func (*Store) GetLatest

func (ms *Store) GetLatest(obj *usher.Object, kind string, qa ...interface{}) *usher.Error

func (*Store) Update

func (ms *Store) Update(obj *usher.Object, id usher.ObjectID, updates []usher.UpdateClause) *usher.Error

Update is used to update an object. Update selectively updates and hence can be used for both PUT and PATCH type implementations. Only changes that are provided through in 'updates' array are applied to the object. If item does not exist in memory, a '404 NotFound' will be returned.

Jump to

Keyboard shortcuts

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