datastore

package
v1.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package datastore is a simple package for tracking of a single instance of application data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finder added in v1.0.0

type Finder interface {
	storm.Finder
}

A Finder can fetch types from BoltDB.

type Manager

type Manager struct {
	Store *storm.DB
	// contains filtered or unexported fields
}

Manager main object for data store.

func New

func New(filePath string) (*Manager, error)

New returns a new datastore Manager.

func Open added in v1.1.0

func Open(fp string) (*Manager, error)

Open returns a datastore Manager. Error if datastore file does not exist.

func (*Manager) All added in v1.0.0

func (m *Manager) All(to interface{}, options ...func(*index.Options)) error

All gets all the records of a bucket. If there are no records it returns no error and the 'to' parameter is set to an empty slice.

func (*Manager) AllByIndex added in v1.0.0

func (m *Manager) AllByIndex(fieldName string, to interface{}, options ...func(*index.Options)) error

AllByIndex gets all the records of a bucket that are indexed in the specified index.

func (*Manager) Count added in v1.0.0

func (m *Manager) Count(data interface{}) (int, error)

Count counts all the records of a bucket.

func (*Manager) Find added in v1.0.0

func (m *Manager) Find(fieldName string, value interface{}, to interface{}, options ...func(*index.Options)) error

Find returns one or more records by the specified index.

func (*Manager) GetPath

func (m *Manager) GetPath() string

GetPath returns the filepath to db file.

func (*Manager) One added in v1.0.0

func (m *Manager) One(fieldName string, value interface{}, to interface{}) error

One returns one record by the specified index.

func (*Manager) Prefix added in v1.0.0

func (m *Manager) Prefix(fieldName string, prefix string, to interface{}, options ...func(*index.Options)) error

Prefix returns one or more records whose given field starts with the specified prefix.

func (*Manager) Range added in v1.0.0

func (m *Manager) Range(fieldName string, min interface{}, max interface{}, to interface{}, options ...func(*index.Options)) error

Range returns one or more records by the specified index within the specified range.

func (*Manager) Save added in v1.0.0

func (m *Manager) Save(data interface{}) error

Save saves data into the datastore.

func (*Manager) Select added in v1.0.0

func (m *Manager) Select(matchers ...q.Matcher) storm.Query

Select a list of records that match a list of matchers. Doesn't use indexes.

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops database and any associated goroutines.

type WriteCloser added in v1.1.0

type WriteCloser interface {
	Save(data interface{}) error
	Stop()
}

A WriteCloser can write to or close a datastore.

type Writer added in v1.0.0

type Writer interface {
	Save(data interface{}) error
}

A Writer can write to a datastore.

Jump to

Keyboard shortcuts

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