models

package
v0.0.0-...-e872591 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReadBucket *gocb.Bucket

Functions

func CloseDbConnection

func CloseDbConnection(db *sql.DB)

CloseDbConnection will end dialogue with the DB Recommanded to use at program's end

func ConnectToCouchBase

func ConnectToCouchBase(host, user, password string)

func ConnectToDB

func ConnectToDB(host string, dbname string, user string, password string, port string)

ConnectToDB Set up connection to the postgres DB Will panic on error

func Hash

func Hash(password string) ([]byte, error)

func VerifyPassword

func VerifyPassword(hashedPassword, password string) error

Types

type Post

type Post struct {
	ID        uint64    `gorm:"not null" json:"id"`
	Title     string    `gorm:"not null" json:"title"`
	Content   string    `gorm:"not null" json:"content"`
	Author    User      `json:"author"`
	AuthorID  uint32    `gorm:"not null" json:"author_id"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

func GetReadModel

func GetReadModel(id string) (Post, gocb.Cas, error)

func (*Post) Validate

func (p *Post) Validate() error

type User

type User struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Nickname  string    `gorm:"size:255;not null;unique" json:"nickname"`
	Email     string    `gorm:"size:100;not null;unique" json:"email"`
	Password  string    `gorm:"size:100;not null;" json:"password"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

func (*User) BeforeSave

func (u *User) BeforeSave() error

func (*User) DeleteAUser

func (u *User) DeleteAUser(db *gorm.DB, uid uint32) (int64, error)

func (*User) FindAllUsers

func (u *User) FindAllUsers(db *gorm.DB) (*[]User, error)

func (*User) FindUserByID

func (u *User) FindUserByID(db *gorm.DB, uid uint32) (*User, error)

func (*User) Prepare

func (u *User) Prepare()

func (*User) SaveUser

func (u *User) SaveUser(db *gorm.DB) (*User, error)

func (*User) UpdateAUser

func (u *User) UpdateAUser(db *gorm.DB, uid uint32) (*User, error)

func (*User) Validate

func (u *User) Validate(action string) error

Jump to

Keyboard shortcuts

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