models

package
v0.0.0-...-d9aeb59 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: MIT Imports: 2 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 {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
}

basicly you can add base columns into all models

type Book

type Book struct {
	Base
	Name         string    `gorm:"not null;size:100" json:"name"`
	Author       string    `gorm:"not null;size:100" json:"author"`
	ReleasedDate time.Time `json:"releasedDate"`
}

type RefreshToken

type RefreshToken struct {
	Base
	UserID uint
	Token  string `json:"token"`
	User   User
}

type RentedBook

type RentedBook struct {
	Base
	UserID           uint
	User             User `gorm:"foreignKey:UserID"`
	RentedBookDetail []RentedBookDetail
}

type RentedBookDetail

type RentedBookDetail struct {
	Base
	RentedBookID uint
	BookID       uint
	Book         Book
}

type Role

type Role struct {
	Base
	Name string `gorm:"unique;size:50" json:"name"`
}

type User

type User struct {
	Base
	Email      string `gorm:"unique;size:100" json:"email"`
	Password   string `gorm:"not null;size:100" json:"password"`
	RoleId     uint   `json:"RoleId"`
	Active     bool   `json:"active"`
	Role       Role
	UserDetail UserDetail
}

type UserDetail

type UserDetail struct {
	Base
	UserID      uint
	FirstName   string    `gorm:"not null;size:100" json:"firstName"`
	LastName    string    `gorm:"not null;size:100" json:"lastName"`
	PhoneNumber string    `gorm:"not null;size:15" json:"phoneNumber"`
	DateOfBirth time.Time `gorm:"not null" json:"dateOfBirth"`
}

Jump to

Keyboard shortcuts

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