Version: v0.0.0-...-05b3b51 Latest Latest

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 4 Imported by: 0


Models package

//TODO: write modules doc




This section is empty.


This section is empty.


This section is empty.


type BaseModel

type BaseModel struct {

BaseModel is base class for all models, created for flexibility later,

* currently same as gorm.Model

type DateT

type DateT time.Time

DateT for date references in database

type DeleterSaver

type DeleterSaver interface {

DeleterSaver interface to define methods for base models with ID

type TimestampT

type TimestampT time.Time

TimestampT for timestamp references in database

type User

type User struct {

	GoogleID        string `gorm:"unique_index;default:null;"`
	FacebookID      string `gorm:"unique_index;default:null;"`
	Password        string `gorm:"default:null;"`
	FirstName       string `gorm:"not null"`
	LastName        string `gorm:"not null"`
	Email           string `gorm:"type:varchar(100);unique_index;not null;"`
	EmailVerifiedAt time.Time
	Role            uint `gorm:"default:1;"`

User is a base model of user

func CheckCredentials

func CheckCredentials(email, password string) *User

CheckCredentials returns user if email-password combination exists, otherwise null

func GetUserByEmail

func GetUserByEmail(email string) *User

GetUserByEmail returns user with given email if exists, otherwise null

func GetUserByID

func GetUserByID(ID uint) *User

GetUserByID returns user with given ID or null

func (*User) Delete

func (u *User) Delete(softDelete bool)

Delete deletes user, softDelete parameter specifies whether value should be deleted permanently

*Primary key (ID) must be set

func (*User) Save

func (u *User) Save()

Save updates model in the database, if primary key isn't set creates model

func (*User) SaveUserIfDoesntExist

func (u *User) SaveUserIfDoesntExist()

SaveUserIfDoesntExist saves user to database if emails isn't occupied

func (*User) ToMap

func (u *User) ToMap() *map[string]interface{}

Return map to be parsed in json response

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL