database

package
v0.0.0-...-5bf4a4b Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package database provides an abstraction layer between the application and the underlying storage.

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("Unable to locate record with the given key")

ErrKeyNotFound is returned when the given key is not in the underlying database.

Functions

This section is empty.

Types

type Manager

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

Manager maintains transactions and handles repository creation.

func New

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

New creates a Manager using the given file.

func (*Manager) Commit

func (dbm *Manager) Commit() error

Commit attempts to persist any changes to the underlying database.

func (*Manager) NewServerRepository

func (dbm *Manager) NewServerRepository() (*ServerRepository, error)

NewServerRepository allocates a fully-wired ServerRepository.

func (*Manager) Rollback

func (dbm *Manager) Rollback() error

Rollback resets any changes made in the current transaction and starts a new one.

type ServerRepository

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

ServerRepository handles persistence and hydration of Server models.

func (*ServerRepository) All

func (repo *ServerRepository) All() ([]model.Server, error)

All returns a slice containing all Servers.

func (*ServerRepository) Delete

func (repo *ServerRepository) Delete(key string) error

Delete attempts to remove a Server defined by the given key.

func (*ServerRepository) Find

func (repo *ServerRepository) Find(key string) (model.Server, error)

Find attempts to locate a Server with the given key.

If a Server is not found, but no other error occurs, a ErrKeyNotFound error will be returned.

func (*ServerRepository) Save

func (repo *ServerRepository) Save(s model.Server) error

Save attempts to persist a given Server.

Jump to

Keyboard shortcuts

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