models

package
v0.0.0-...-f1a1644 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	// contains filtered or unexported fields
}

func (*Base) DeleteById

func (b *Base) DeleteById(tx *sqlx.Tx, id int64) (sql.Result, error)

func (*Base) DeleteFromTable

func (b *Base) DeleteFromTable(tx *sqlx.Tx, where string) (sql.Result, error)

func (*Base) InsertIntoTable

func (b *Base) InsertIntoTable(tx *sqlx.Tx, data map[string]interface{}) (sql.Result, error)

func (*Base) UpdateByID

func (b *Base) UpdateByID(tx *sqlx.Tx, data map[string]interface{}, id int64) (sql.Result, error)

func (*Base) UpdateByKeyValueString

func (b *Base) UpdateByKeyValueString(tx *sqlx.Tx, data map[string]interface{}, key, value string) (sql.Result, error)

func (*Base) UpdateFromTable

func (b *Base) UpdateFromTable(tx *sqlx.Tx, data map[string]interface{}, where string) (sql.Result, error)

type User

type User struct {
	Base
}

func NewUser

func NewUser(db *sqlx.DB) *User

func (*User) AllUsers

func (u *User) AllUsers(tx *sqlx.Tx) ([]*UserRow, error)

AllUsers returns all user rows.

func (*User) GetByEmail

func (u *User) GetByEmail(tx *sqlx.Tx, email string) (*UserRow, error)

GetByEmail returns record by email.

func (*User) GetById

func (u *User) GetById(tx *sqlx.Tx, id int64) (*UserRow, error)

GetById returns record by id.

func (*User) GetUserByEmailAndPassword

func (u *User) GetUserByEmailAndPassword(tx *sqlx.Tx, email, password string) (*UserRow, error)

GetByEmail returns record by email but checks password first.

func (*User) Signup

func (u *User) Signup(tx *sqlx.Tx, email, password, passwordAgain string) (*UserRow, error)

Signup create a new record of user.

func (*User) UpdateEmailAndPasswordById

func (u *User) UpdateEmailAndPasswordById(tx *sqlx.Tx, userId int64, email, password, passwordAgain string) (*UserRow, error)

UpdateEmailAndPasswordById updates user email and password.

type UserRow

type UserRow struct {
	ID       int64  `db:"id"`
	Email    string `db:"email"`
	Password string `db:"password"`
}

Jump to

Keyboard shortcuts

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