storage

package
v0.0.0-...-841f565 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	ID string
	// contains filtered or unexported fields
}

Collection represents a location in the database that holds keys and values This can be nested inside other Collections

func NewCollection

func NewCollection(paths []string, txn DBTxn, parent *Collection) (*Collection, error)

NewCollection recursively creates a collection starting at the given root

func (*Collection) Collection

func (c *Collection) Collection(id string) (*Collection, error)

Collection creates a nested collection

func (*Collection) Get

func (c *Collection) Get(key string, v interface{}) (bool, error)

Get returns a value from the collection by its key

func (*Collection) Path

func (c *Collection) Path(path ...string) []string

Path returns the path to the collection by traversing it's parents IDs

func (*Collection) Put

func (c *Collection) Put(key string, v interface{}) error

Put sets a value in the collection by its key

func (*Collection) String

func (c *Collection) String() string

String

type DBRoot

type DBRoot interface {
	DBTxn
	Get(key []byte) []byte
	Put(key []byte, data []byte) error
}

DBRoot an interface that describes a database storage root allowing you to store and retrieve data

type DBTxn

type DBTxn interface {
	Bucket(key []byte) *bolt.Bucket
	CreateBucketIfNotExists(key []byte) (*bolt.Bucket, error)
}

DBTxn an interface that describes a database storage root allow you to create nested roots

type Database

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

Database a storage interface

func Open

func Open(path string) (*Database, error)

Open creates a connection to the database

func (*Database) Close

func (d *Database) Close() error

Close safely disconnects the database

func (*Database) Collection

func (d *Database) Collection(path string, txn DBTxn) (*Collection, error)

Collection creates a collection from the root at the given path Use a `/` to create a nested collection

func (*Database) Transaction

func (d *Database) Transaction(run TxnRunner) error

Transaction starts a transaction

type TxnRunner

type TxnRunner func(tx *bolt.Tx) error

TxnRunner a function that runs inside of a transaction If an error is returned the transaction is rolled back

Jump to

Keyboard shortcuts

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