Documentation ¶
Index ¶
Constants ¶
const DefaultDataFileName = "hyper.db"
DefaultDataFileName is the default file name of the database file.
Variables ¶
var ( // ErrCannotCloseNilDB is an error returned when attempted to close nil database. ErrCannotCloseNilDB = errors.New("attempted to close nil database") // ErrCannotCloseNilBoltDB is an error returned when attempted to close nil Bolt database. ErrCannotCloseNilBoltDB = errors.New("attempted to close nil Bolt database") )
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
Attribute is a set property of an object that needs to be indexed in the db to be easily findable.
type AttributeBase ¶
AttributeBase is a naive hyperdb implementation of the Attribute interface.
func (AttributeBase) GetName ¶
func (ab AttributeBase) GetName() string
GetName returns the name of the AttributeBase object.
func (AttributeBase) GetType ¶
func (ab AttributeBase) GetType() string
GetType returns the type of the AttributeBase object.
func (AttributeBase) GetValue ¶
func (ab AttributeBase) GetValue() []byte
GetValue returns the value of the AttributeBase object.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a collection of objects with multitude of attributes, that can be retrieved based all possible dimensions.
func Open ¶
Open creates and opens a database at the given path. If the file doesn't exist, it is created automatically.
func (*DB) Get ¶
Get looks up the ids of the objects that fit the search criteria and returns them to the client.
func (*DB) Put ¶
func (db *DB) Put(obj HyperObject) (string, error)
Put adds an object to the database if it does not exist, or updates existing entries based on the new object definition. The function returns unique id of the object stored in hyperdb that can later be used to update or remove object in/from the namespace.
type HyperObject ¶
type HyperObject interface { // GetId returns a unique ID of the object the hyperdb client wants to // use as a reference for the object. If 0 is returned, hyperdb assigns its // own ID. GetID() string // GetAttributes returns a slice of all the attributes of the object. GetAttributes() []Attribute }
HyperObject is an interface expected to be implemented by the objects that are about to be stored in the hyperdb.
type HyperObjectBase ¶
HyperObjectBase is a built-in naive implementation of the HyperObject interface.
func (HyperObjectBase) GetAttributes ¶
func (hob HyperObjectBase) GetAttributes() []Attribute
func (HyperObjectBase) GetID ¶
func (hob HyperObjectBase) GetID() string