pdb

package
v0.7.3-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2016 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGotNilPointer = errors.New("Got a nil pointer as input.")

ErrGotNilPointer is, when a function gets a nil pointer

View Source
var ErrPersonDeleted = errors.New("Person instance inside the db was deleted.")

ErrPersonDeleted describes, when a person is not any more inside the db.

Functions

This section is empty.

Types

type PersonDB

type PersonDB struct {
	Root        string                 `json:"rootFolder"`
	PictureRoot string                 `json:"pictureRootFolder"`
	NextID      int                    `json:"nextID"`
	Persons     map[string]data.Person `json:"Persons"`
}

PersonDB is the struct for storing all the persons.

func Load

func Load(root, pictureRoot string) (*PersonDB, error)

func New

func New(root, pictureRoot string) *PersonDB

func (*PersonDB) AddPerson

func (pdb *PersonDB) AddPerson(p *data.Person)

AddPerson adda data.Person to the pdb instance. If the person has no ID a new ID is created and set to the person.

func (*PersonDB) EditPerson

func (pdb *PersonDB) EditPerson(p *data.Person) error

EditPerson handles if data inside the person has changed. It is compulsory that the person has a valid ID.

func (*PersonDB) FindPerson

func (pdb *PersonDB) FindPerson(p *data.Person) (*data.Person, bool)

FindPerson takes a Person and searches with the name if there is an entry in the db. If there is a person with that name it returns the ID and true. If no person is found it return 0 and false

func (*PersonDB) GetAll

func (pdb *PersonDB) GetAll() map[string]data.Person

GetAll returns all the persons inside the DB as map

func (*PersonDB) GetPerson

func (pdb *PersonDB) GetPerson(id string) (*data.Person, bool)

GetPerson by Person.ID. Second parameter returns true if an entry is found. If there is no such ID inside the pdb the function return nil, false

func (*PersonDB) GetProfilePics

func (pdb *PersonDB) GetProfilePics(p *data.Person)

func (*PersonDB) SavePerson

func (pdb *PersonDB) SavePerson(p *data.Person) error

SavePerson takes a Person and saves the data inside the struct. That method should always be used to save Person data to ensure that the person always get an ID. If the input person has no ID the NextID is set to the person and counter +1.

func (*PersonDB) UpdatePictures

func (pdb *PersonDB) UpdatePictures(root string)

UpdatePictures regenerates the references to a person, which has a masterID.

Jump to

Keyboard shortcuts

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