model

package
v0.0.0-...-e1bbea1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func CreateAdmin

func CreateAdmin()

func Init

func Init() *gorm.DB

func Register

func Register(username, password string) error

func Save

func Save(object interface{}) error

func UpdatePost

func UpdatePost(pid interface{}, attrs map[string]interface{}) error

func UpdateUser

func UpdateUser(uid interface{}, attrs map[string]interface{}) error

Types

type Comment

type Comment struct {
	gorm.Model
	Content string `json:"content"`
	UserID  uint   `json:"userid"`
	PostID  uint   `json:"postid"`
}

type Post

type Post struct {
	gorm.Model
	Title    string    `json:"title"`
	Content  string    `json:"content"`
	Comments []Comment `json:"comments"`
	Hidden   bool      `gorm:"default:false" json:"hidden"`
	UserID   uint      `json:"userid"`
}

func CreateComment

func CreateComment(pid interface{}, comment Comment) (*Post, error)

func FetchPosts

func FetchPosts(doHidePost bool, limit int, offset int) ([]Post, error)

func FindPostByID

func FindPostByID(pid interface{}) (*Post, error)

func SearchPost

func SearchPost(keyword string) ([]Post, error)

type User

type User struct {
	gorm.Model
	Username       string `gorm:"uniqueIndex"`
	HashedPassword []byte
	Active         bool `gorm:"default:true"`
}

func FindUserByID

func FindUserByID(uid interface{}) (*User, error)

func FindUserByName

func FindUserByName(name interface{}) (*User, error)

func Login

func Login(username, password string) (*User, error)

Jump to

Keyboard shortcuts

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