models

package
v0.0.0-...-00b2d59 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2015 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Global DB connection

Functions

func Migrate

func Migrate()

Migrate the database

func New

func New(con string) error

New initalizes the database

func ValidateUser

func ValidateUser(id, email, password string) (e []validate.ValidationMsg)

ValidateUser validates user models

Types

type User

type User struct {
	ID       string `sql:"not null;unique" json:"id"`
	Email    string `sql:"not null;unique" json:"email"`
	Password string `sql:"not null" json:"-"`
}

User is the structure of the user model.

func GetUser

func GetUser(id, email string) (*User, error)

GetUser retrives a user by email

func NewUser

func NewUser(email, password string) (*User, []validate.ValidationMsg, error)

NewUser creates a new user object if it is valid.

func (User) CheckPass

func (u User) CheckPass(password string) bool

CheckPass checks if the password matches the users hash.

func (*User) Update

func (u *User) Update(email, password string) ([]validate.ValidationMsg, error)

Update updates an existing user.

Jump to

Keyboard shortcuts

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