contacts

package
v0.0.0-...-d78814b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB is a reference to the parent app's gorm DB.

Functions

func Add

func Add(c *Contact) error

Add a new contact.

func UseDB

func UseDB(db *gorm.DB)

UseDB registers the DB from the root app.

Types

type ByName

type ByName []*Contact

ByName sorts contacts by name.

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type Contact

type Contact struct {
	ID        int       `json:"id"`
	Secret    string    `json:"secret" gorm:"unique"` // their lazy insecure login token
	FirstName string    `json:"firstName"`
	LastName  string    `json:"lastName"`
	Email     string    `json:"email"`
	SMS       string    `json:"sms"`
	LastSeen  time.Time `json:"lastSeen"`
	Created   time.Time `json:"created"`
	Updated   time.Time `json:"updated"`
}

Contact is an individual contact in the address book.

func Get

func Get(id int) (Contact, error)

Get a contact by ID.

func GetBySecret

func GetBySecret(secret string) (Contact, error)

GetBySecret queries a contact by their secret.

func GetEmail

func GetEmail(email string) (Contact, error)

GetEmail queries a contact by email address.

func GetSMS

func GetSMS(number string) (Contact, error)

GetSMS queries a contact by SMS number.

func NewContact

func NewContact() Contact

NewContact initializes a new contact entry.

func (Contact) Name

func (c Contact) Name() string

Name returns a friendly name for the contact.

func (*Contact) ParseForm

func (c *Contact) ParseForm(r *http.Request)

ParseForm accepts form data for a contact.

func (Contact) Save

func (c Contact) Save() error

Save the contact.

func (Contact) Validate

func (c Contact) Validate() error

Validate the contact form.

type Contacts

type Contacts []Contact

Contacts is the plurality of all contacts.

func All

func All() (Contacts, error)

All contacts from the database alphabetically sorted.

Jump to

Keyboard shortcuts

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