crud

package
v0.10.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const MongoCollectionPrefix = "cnab_"

MongoCollectionPrefix is applied to every collection.

Variables

View Source
var ErrRecordDoesNotExist = errors.New("File does not exist")

ErrRecordDoesNotExist represents when file path is not found on file system

Functions

This section is empty.

Types

type BackingStore

type BackingStore struct {
	AutoClose bool
	// contains filtered or unexported fields
}

BackingStore wraps another store that may have Connect/Close methods that need to be called. - Connect is called before a method when the connection is closed. - Close is called after each method when AutoClose is true (default).

func NewBackingStore

func NewBackingStore(store Store) *BackingStore

func (*BackingStore) Close

func (s *BackingStore) Close() error

func (*BackingStore) Connect

func (s *BackingStore) Connect() error

func (*BackingStore) Delete

func (s *BackingStore) Delete(itemType string, name string) error

func (*BackingStore) List

func (s *BackingStore) List(itemType string) ([]string, error)

func (*BackingStore) Read

func (s *BackingStore) Read(itemType string, name string) ([]byte, error)

func (*BackingStore) ReadAll

func (s *BackingStore) ReadAll(itemType string) ([][]byte, error)

ReadAll retrieves all the items.

func (*BackingStore) Save

func (s *BackingStore) Save(itemType string, name string, data []byte) error

type HasClose

type HasClose interface {
	Close() error
}

HasClose indicates that a struct must be cleaned up using the Close method before the interface's methods are called.

type HasConnect

type HasConnect interface {
	Connect() error
}

HasConnect indicates that a struct must be initialized using the Connect method before the interface's methods are called.

type Store

type Store interface {
	List(itemType string) ([]string, error)
	Save(itemType string, name string, data []byte) error
	Read(itemType string, name string) ([]byte, error)
	Delete(itemType string, name string) error
}

Store is a simplified interface to a key-blob store supporting CRUD operations.

func NewFileSystemStore

func NewFileSystemStore(baseDirectory string, fileExtension string) Store

NewFileSystemStore creates a Store backed by a file system directory. Each key is represented by a file in that directory.

func NewMongoDBStore

func NewMongoDBStore(url string) Store

NewMongoDBStore creates a new storage engine that uses MongoDB

The URL provided must point to a MongoDB server and database.

Jump to

Keyboard shortcuts

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