Documentation ¶
Index ¶
- Variables
- type PersonDB
- func (pdb *PersonDB) AddPerson(p *data.Person)
- func (pdb *PersonDB) EditPerson(p *data.Person) error
- func (pdb *PersonDB) FindPerson(p *data.Person) (*data.Person, bool)
- func (pdb *PersonDB) GetAll() map[string]data.Person
- func (pdb *PersonDB) GetPerson(id string) (*data.Person, bool)
- func (pdb *PersonDB) GetProfilePics(p *data.Person)
- func (pdb *PersonDB) SavePerson(p *data.Person) error
- func (pdb *PersonDB) UpdatePictures(root string)
Constants ¶
This section is empty.
Variables ¶
var ErrGotNilPointer = errors.New("Got a nil pointer as input.")
ErrGotNilPointer is, when a function gets a nil pointer
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 (*PersonDB) AddPerson ¶
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 ¶
EditPerson handles if data inside the person has changed. It is compulsory that the person has a valid ID.
func (*PersonDB) FindPerson ¶
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) GetPerson ¶
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 (*PersonDB) SavePerson ¶
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 ¶
UpdatePictures regenerates the references to a person, which has a masterID.