model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Book

type Book struct {
	ID        uuid.UUID  `db:"id" json:"id" validate:"uuid"`
	CreatedAt time.Time  `db:"created_at" json:"created_at"`
	UpdatedAt *time.Time `db:"updated_at" json:"updated_at"`
	IsDeleted bool       `db:"is_deleted" json:"is_deleted"`
	UserID    int        `db:"user_id" json:"user_id" validate:"required"`
	Title     string     `db:"title" json:"title" validate:"required,lte=255"`
	Author    string     `db:"author" json:"author" validate:"required,lte=255"`
	Status    int        `db:"status" json:"status" validate:"required,len=1"`
	Meta      Meta       `db:"meta" json:"meta" validate:"required,dive"`
}

Book struct to describe book object.

func NewBook

func NewBook() *Book

type CreateUser

type CreateUser struct {
	IsAdmin   bool   `json:"is_admin"`
	IsActive  bool   `json:"is_active"`
	UserName  string `json:"username" validate:"required,lte=50,gte=5"`
	Email     string `json:"email" validate:"required,email,lte=150"`
	Password  string `json:"password" validate:"required,lte=100,gte=10"`
	FirstName string `json:"first_name" validate:"required,lte=100"`
	LastName  string `json:"last_name" validate:"required,lte=100"`
}

type Meta

type Meta struct {
	Picture     string `json:"picture"`
	Description string `json:"description"`
	Rating      int    `json:"rating" validate:"min=1,max=10"`
}

Meta struct to describe book attributes.

func (*Meta) Scan

func (b *Meta) Scan(value interface{}) error

Scan make the Book Meta struct implement the sql.Scanner interface. This method simply decodes a JSON-encoded value into the struct fields.

func (Meta) Value

func (b Meta) Value() (driver.Value, error)

Value make the Book Meta struct implement the driver.Valuer interface. This method simply returns the JSON-encoded representation of the struct.

type UpdateUser

type UpdateUser struct {
	IsAdmin   bool   `json:"is_admin"`
	IsActive  bool   `json:"is_active"`
	FirstName string `json:"first_name" validate:"required,lte=100"`
	LastName  string `json:"last_name" validate:"required,lte=100"`
}

type User

type User struct {
	ID        int        `db:"id"`
	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt *time.Time `db:"updated_at"`
	IsActive  bool       `db:"is_active"`
	IsDeleted bool       `db:"is_deleted"`
	IsAdmin   bool       `db:"is_admin"`
	UserName  string     `db:"username"`
	Email     string     `db:"email"`
	Password  string     `db:"password"`
	FirstName string     `db:"first_name"`
	LastName  string     `db:"last_name"`
}

User struct to describe User object.

func NewUser

func NewUser() *User

Jump to

Keyboard shortcuts

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