models

package
v0.0.0-...-7e63fe4 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNew

func CreateNew(email, password, name string) (id int64, err error)

Create a new user

Types

type BasicCredentials

type BasicCredentials struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Define basic credentials struct

type InputUser

type InputUser struct {
	Email    string `json:"email"`
	Password string `json:"password"`
	Name     string `json:"name"`
}

User model struct (input object)

type User

type User struct {
	Id       int64     `json:"id"`
	Email    string    `json:"email" orm:"unique;index;size(191)"`
	Password string    `json:"-"`
	Name     string    `json:"name"`
	Created  time.Time `json:"created_on" orm:"auto_now_add;type(datetime)"`
	Updated  time.Time `json:"updated_on" orm:"auto_now;type(datetime)"`
}

User model struct (database & response)

func FindByEmail

func FindByEmail(email string) (user *User, err error)

Find an user by email

func FindById

func FindById(id int64) (user *User, err error)

Find an user by ID

func IndexAll

func IndexAll() (users []User, err error)

func Login

func Login(email, password string) (user *User, err error)

Login method for user

func (*User) TableName

func (u *User) TableName() string

Custom table name

Jump to

Keyboard shortcuts

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