models

package
v0.0.0-...-9a9f523 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Post

type Post struct {
	ID        int            `json:"id"`
	Title     string         `json:"title"`
	Slug      string         `json:"slug"`
	Body      string         `json:"body"`
	UserID    int            `json:"userId"`
	Author    string         `json:"author,omitempty"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt mysql.NullTime `json:"updatedAt"`
}

func (*Post) MarshalJSON

func (p *Post) MarshalJSON() ([]byte, error)

type User

type User struct {
	ID        int            `json:"id"`
	Name      string         `json:"name"`
	Email     string         `json:"email"`
	Password  string         `json:"password"`
	Admin     bool           `json:"admin"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt mysql.NullTime `json:"updatedAt"`
}

User represents a user account Make sure not to expose the password field when marshalling to json

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) MarshalJSON

func (u *User) MarshalJSON() ([]byte, error)

TODO: Maybe find a better solution to remove the password when marshalling to json

func (*User) SetPassword

func (u *User) SetPassword(password string)

Jump to

Keyboard shortcuts

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