Documentation
¶
Index ¶
- func EnsureDBExists(cfg *config.Config) error
- func TestDBExistence(cfg *config.Config) error
- func TestDBHost(cfg *config.Config) error
- type Client
- type Contact
- type Invoices
- func (db *Invoices) AddClient(c *Client) (int64, error)
- func (db *Invoices) AddContact(c *Contact) (int64, error)
- func (db *Invoices) GetAllClients() ([]*Client, error)
- func (db *Invoices) GetAllContacts() ([]*Contact, error)
- func (db *Invoices) GetClient(id int64) *Client
- func (db *Invoices) GetClients(keyword string) ([]*Client, error)
- func (db *Invoices) GetContact(id int64) *Contact
- func (db *Invoices) GetContacts(keyword string) ([]*Contact, error)
- func (db *Invoices) RemoveClient(id int64) error
- func (db *Invoices) RemoveContact(id int64) error
- func (db *Invoices) UpdateClient(c *Client) error
- func (db *Invoices) UpdateContact(c *Contact) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDBExists ¶
EnsureDBExists creates the database and the correct tables.
func TestDBExistence ¶
TestDBExistence checks for the host and the database.
Types ¶
type Client ¶
type Client struct {
// ID is autogenerated.
ID int64
// Company is the primary string reference.
Company string
// Email is the primary contact. Add to the contacts table for more.
Email string
// Phone if applicable.
Phone string
// Address to print on invoices.
Address string
// VATID or org. no.
VATID string
// Created timestamp.
Created time.Time
}
Client structure translated from the database.
type Contact ¶ added in v0.2.0
type Contact struct {
// ID in the database.
ID int64
// Name of person. Non-unique to allow multiple e-mails or phone numbers.
Name string
// Email to contact them at. May be blank.
Email string
// Phone number to contact them at. May be blank.
Phone string
// Client they work for.
Client int64
// Created timestamp.
Created time.Time
}
Contact structure from the database.
type Invoices ¶
Invoices is the name of our DB type to make it clear this isn't generic.
func (*Invoices) AddContact ¶ added in v0.2.0
AddContact returns the contact ID on success.
func (*Invoices) GetAllClients ¶
GetAllClients returns all clients.
func (*Invoices) GetAllContacts ¶ added in v0.2.0
GetAllContacts returns all contacts.
func (*Invoices) GetClients ¶
GetClients returns all matching clients.
func (*Invoices) GetContact ¶ added in v0.2.0
GetContact returns one contact by ID.
func (*Invoices) GetContacts ¶ added in v0.2.0
GetContacts returns all matching contacts.
func (*Invoices) RemoveClient ¶
RemoveClient from database.
func (*Invoices) RemoveContact ¶ added in v0.2.0
RemoveContact from database.
func (*Invoices) UpdateClient ¶
UpdateClient changes the details of a client.
func (*Invoices) UpdateContact ¶ added in v0.2.0
UpdateContact changes the details of a contact.