db

package
v0.0.0-...-72e6ce5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB is the accessible database.

Functions

func Close

func Close()

Close the database.

func Init

func Init()

Init makes sure the database has the correct tables.

func InitSQLite

func InitSQLite()

InitSQLite starts the sqlite database.

Types

type Contact

type Contact struct {
	gorm.Model

	Name   string `json:"name"`
	Email  string `json:"email"`
	Number string `json:"number,omitempty"`
	Slug   string `json:"slug"`

	Notes []Note `json:"notes,omitempty"`

	Lead       bool   `json:"lead,omitempty"`
	Advocate   bool   `json:"advocate,omitempty"`
	Customer   bool   `json:"customer,omitempty"`
	Subscriber bool   `json:"subscriber,omitempty"`
	Other      string `json:"other"`
	Contacted  bool   `json:"contacted"`
}

Contact is the main person.

func QueryContacts

func QueryContacts() ([]Contact, error)

QueryContacts returns all of the contacts in the database.

func (*Contact) Create

func (c *Contact) Create() error

Create a contact in the database.

func (*Contact) Query

func (c *Contact) Query() error

Query a contact given an ID.

func (*Contact) Remove

func (c *Contact) Remove() error

Remove a contact that is in the database.

func (*Contact) Search

func (c *Contact) Search() (err error)

Search returns a single contact that matches c.

func (*Contact) SearchMultiple

func (c *Contact) SearchMultiple() (result []Contact, err error)

SearchMultiple returns multiple contacts that match c.

func (*Contact) Update

func (c *Contact) Update() error

Update a contact that is in the database.

type Email

type Email struct {
	gorm.Model

	To      string `json:"to"`
	Bcc     string `json:"bcc,omitempty"`
	Subject string `json:"subject"`
	Body    string `json:"body"`
}

Email entry in the database.

type Note

type Note struct {
	gorm.Model
	ContactID uint

	Text string `json:"text"`

	Task bool      `json:"task,omitempty"`
	Due  time.Time `json:"due_date,omitempty"`

	Call  bool      `json:"call,omitempty"`
	Email bool      `json:"email,omitempty"`
	Event time.Time `json:"event,omitempty"`
}

Note has information about a contact.

func QueryNotes

func QueryNotes() ([]Note, error)

QueryNotes will return all of the notes.

func (*Note) Create

func (n *Note) Create() error

Create a single note.

func (*Note) Query

func (n *Note) Query() error

Query a note given an ID.

func (*Note) Remove

func (n *Note) Remove() error

Remove a single note.

func (*Note) Update

func (n *Note) Update() error

Update a single note.

Jump to

Keyboard shortcuts

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