database

package
v0.0.0-...-04f6069 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AutoIncrement sets the object's key as an auto incrementing ID
	AutoIncrement = iota + 1
	// GetFirstKey gets the first object in a bucket
	GetFirstKey
	// GetLastKey gets the last object in a bucket
	GetLastKey
)

Variables

View Source
var (

	// BucketQueued key, holds Torrent hash keys by auto ID that are queued for activity
	BucketQueued = []byte("Queued")
	// BucketTorrents key, holds Torrents by hash key, contains static info and magnet URLs
	BucketTorrents = []byte("Torrents")
	// BucketLabels key, holds user created Labels by unique short id
	BucketLabels = []byte("Labels")
	// ErrKeyNotValid if it's not metainfo.Hash, byte slice, string, struct pointer, GetFirstKey or GetLastKey
	ErrKeyNotValid = errors.New("key does not satisfy interface requirements")
	// ErrValueNotValid if it's not metainfo.Hash, byte slice, string, struct pointer, or AutoIncrement
	ErrValueNotValid = errors.New("value does not satisfy interface requirements")
	// ErrNoSuchKey if an object doesn't exist with the specified key
	ErrNoSuchKey = errors.New("no such key exists")
)

Functions

func All

func All(bucket []byte) [][]byte

All returns all stored objects as a slice within the provided bucket. If there are no objects then nil is returned.

func Close

func Close()

Close the database

func Delete

func Delete(bucket []byte, key interface{}) error

Delete returns the object held by key within the provided bucket. Key must be a type of metainfo.Hash, byte slice, string, GetFirstKey, or GetLastKey.

func Get

func Get(bucket []byte, key interface{}) ([]byte, error)

Get retrieves a value by the provided key interface. Key must be a type of metainfo.Hash, byte slice, string, GetFirstKey, or GetLastKey.

func Open

func Open(dbFile string) error

Open and initialize the database

func Put

func Put(bucket []byte, key, val interface{}) error

Put stores the value by its provided key and bucket. Key must be a type of metainfo.Hash, byte slice, string, or AutoIncrement. Val must be a type of metainfo.Hash, byte slice, string, or a struct that can be marshaled into JSON format.

func Update

func Update(fn func(tx *bolt.Tx) error) error

Update provides a wrapper for the underlying Bolt DB

func View

func View(fn func(tx *bolt.Tx) error) error

View provides a wrapper for the underlying Bolt DB

Types

This section is empty.

Jump to

Keyboard shortcuts

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