storage

package
v0.0.0-...-a5a6d41 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package storage handles the primary data store

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned if the record was not found in the storage
	ErrNotFound = errors.New("Record not found")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Name                 string
	Username             string
	Password             string
	AuthenticationSource string
	Hosts                []string
	DialTimeout          time.Duration
	Timeout              time.Duration
}

Config struct holds all the configurations required for the store

type DocMeta

type DocMeta struct {
	Count int
	ID    string
}

DocMeta is the document meta generated after performing any store actions

type Service

type Service interface {
	// Save saves given data into the store and return the meta info and error if any
	Save(bucket string, data interface{}) (*DocMeta, error)

	// Update updates the first record matching the given query and new data
	Update(bucket string, query interface{}, data interface{}) error

	// Delete deletes the first record matching the provided query
	Delete(collectionName string, query interface{}) error

	// Find finds all the records matching the query
	Find(bucket string, query, selectFields interface{}, sort []string, start, limit int, result interface{}) ([]map[string]interface{}, error)

	// FindOne finds the first matching document for the given query
	FindOne(bucket string, query, selectFields interface{}, sort []string, result interface{}) (map[string]interface{}, error)
}

Service defines all the methods implemented by the store

func New

func New(c Config) (Service, error)

New returns a new Service instance

type Store

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

Store holds all the dependencies

func (*Store) Delete

func (s *Store) Delete(bucket string, query interface{}) error

Delete deletes the first record matching the query

func (*Store) Find

func (s *Store) Find(bucket string, query, selectFields interface{}, sort []string, start, limit int, result interface{}) ([]map[string]interface{}, error)

Find finds all the records based on the provided query

func (*Store) FindOne

func (s *Store) FindOne(bucket string, query, selectFields interface{}, sort []string, result interface{}) (map[string]interface{}, error)

FindOne finds the first document matching the provided query

func (*Store) Save

func (s *Store) Save(bucket string, data interface{}) (*DocMeta, error)

Save saves data into the primary store

func (*Store) Update

func (s *Store) Update(bucket string, query interface{}, data interface{}) error

Update updates the first record matching the query

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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