Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound occurs when a specific item could not be found. ErrNotFound = errors.New("item not found") // ErrBadTransaction occurs when a write-action is aborted early because of a faulty transaction. ErrBadTransaction = errors.New("abort early: previous error causes transaction rollback") )
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { Action txAction Err error // contains filtered or unexported fields }
Error combines error with context information.
func (Error) Error ¶
Error implements the built-in error interface.
It combines the action, type info and inner error.
func (Error) IsBadTransaction ¶
IsBadTransaction returns true if the inner error is ErrBadTransaction.
func (Error) IsNotFound ¶
IsNotFound returns true if the inner error is ErrNotFound.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store can store and retrieve structs.
func (*Store) Close ¶
Close releases all database resources. All transactions must be closed before closing the database.
func (*Store) Read ¶
Read executes a function within the context of a managed read-only transaction. Any error that is returned from the function is returned from the Read() method.
func (*Store) Register ¶
Register validates struct types for later use. This will require a write-transaction if the the struct type has never been registered in this store or its definition has been changed since the last call. A struct's type must be registered before it can be used in combination with a Store.
func (*Store) Write ¶
Write executes a function within the context of a read-write managed transaction. If no error is returned from the function then the transaction is committed. If an error is returned then the entire transaction is rolled back. Any error that is returned from the function or returned from the commit is returned from the Write() method.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a read-only or read-write transaction.
func (*Tx) Delete ¶
Delete removes the given item.
If the item does not exist a nil error is returned.
func (*Tx) Insert ¶
Insert saves a new item. If an item with the same ID exists an error is returned.