database

package
v0.0.0-...-f5b748a Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkshopLimit = 24
)

Variables

This section is empty.

Functions

func AddChangeLog

func AddChangeLog(item ChangeLog)

func AlreadyLikes

func AlreadyLikes(liker string, postID bson.ObjectId) bool

func ChangeLogExist

func ChangeLogExist(postID bson.ObjectId, unix int64) bool

func CodeInUseWorkshop

func CodeInUseWorkshop(code string) bool

func DeleteComments

func DeleteComments(id bson.ObjectId)

func DeleteLike

func DeleteLike(liker string, postID bson.ObjectId)

func DeleteWorkshop

func DeleteWorkshop(id bson.ObjectId)

func UpdateChangeLog

func UpdateChangeLog(content string, postID bson.ObjectId, unix int64)

func WorkshopCountLikes

func WorkshopCountLikes(id bson.ObjectId) int

func WorkshopCreatorCount

func WorkshopCreatorCount(creator string) int

Types

type ChangeLog

type ChangeLog struct {
	ID      bson.ObjectId `bson:"_id,omitempty" json:"-"`
	PostID  bson.ObjectId `bson:"_post"`
	Content string        `bson:"content"`
	Code    string        `bson:"code"`
	Version string        `bson:"version"`
	Posted  time.Time     `bson:"posted"`
	Unix    int64         `bson:"unix"`
}

func GetChangeLogs

func GetChangeLogs(postID bson.ObjectId, limit int) []ChangeLog

func LatestChangeLog

func LatestChangeLog(postID bson.ObjectId) ChangeLog

type Comment

type Comment struct {
	ID      bson.ObjectId `bson:"_id,omitempty" json:"-"`
	PostID  bson.ObjectId `bson:"parent" json:"-"`
	Author  string        `bson:"author" form:"-"`
	Comment string        `bson:"comment" form:"comment"`
	Posted  time.Time     `bson:"posted" form:"-"`
	Unix    int64         `bson:"unix" form:"-"`
}

func AddComment

func AddComment(comment Comment, parent bson.ObjectId) Comment

func GetComments

func GetComments(parent bson.ObjectId, page, limit int) ([]Comment, int)

type Like

type Like struct {
	ID        bson.ObjectId `bson:"_id,omitempty" json:"-"`
	PostID    bson.ObjectId `bson:"parent" json:"-"`
	Liker     string        `bson:"liker" json:"liker"`
	Liked     time.Time     `bson:"liked"`
	LikedUnix int64         `bson:"liked_unix"`
}

func AddLike

func AddLike(like Like) Like

type User

type User struct {
	ID        bson.ObjectId `bson:"_id,omitempty" json:"-"`
	NickName  string        `bson:"nick"`
	BattleID  string        `bson:"bid"`
	URL       string        `bson:"url" form:"url"`
	ShortID   string        `bson:"short_id"`
	Name      string        `bson:"name" form:"name"`
	NameLower string        `bson:"name_lower"`
	Image     string        `bson:"image" form:"-"`
	ImagePath string        `bson:"image_path" form:"-"`

	// NoBSON
	Mode string `bson:"-" form:"mode"`
	Type string `bson:"-" form:"type"`
	Code string `bson:"-" form:"code"` // Never used
}

func BulkFindUser

func BulkFindUser(ids ...string) []User

func GetUser

func GetUser(id string) User

func UpdateUser

func UpdateUser(user User) User

func UpsertUser

func UpsertUser(current goth.User) User

func (User) GetID

func (u User) GetID() string

func (User) GetNickNameNoTag

func (u User) GetNickNameNoTag() string

type Workshop

type Workshop struct {
	ID          bson.ObjectId `bson:"_id,omitempty" json:"-"`
	ShortID     string        `bson:"short_id" json:"-"`
	Code        string        `bson:"code" form:"code"`
	Title       string        `bson:"title" form:"title"`
	TLDR        string        `bson:"tldr" form:"tldr"`
	Description string        `bson:"desc" form:"desc"`
	Snippet     string        `bson:"snippet" form:"snippet"`
	Privacy     int           `bson:"privacy" form:"privacy"`
	Version     string        `bson:"version" form:"version"`
	Image       string        `bson:"image" form:"-"`
	ImagePath   string        `bson:"image_path" form:"-"`
	Mode        string        `bson:"-" form:"mode"`
	PostID      string        `bson:"-" form:"post_id"`
	ChangeLog   string        `bson:"-" form:"change_log"`
	Author      string        `bson:"author" form:"-"`
	Views       int64         `bson:"views" form:"-"`
	Score       float64       `bson:"score"`

	Posted      time.Time `bson:"posted" form:"-"`
	Unix        int64     `bson:"unix" form:"-"`
	Updated     time.Time `bson:"updated" form:"-"`
	UpdatedUnix int64     `bson:"updated_unix" form:"-"`

	// NoBSON
	Type string `bson:"-" form:"type"`
}

func AddWorkshop

func AddWorkshop(item Workshop) Workshop

func ImportWorkshop

func ImportWorkshop(item Workshop) Workshop

func RandomWorkshop

func RandomWorkshop() Workshop

func SearchWorkShop

func SearchWorkShop(query bson.M, page, limit int, sort string) ([]Workshop, int)

func SingleWorkshop

func SingleWorkshop(id string) Workshop

func UpdateWorkshop

func UpdateWorkshop(item Workshop) Workshop

func (Workshop) GetID

func (w Workshop) GetID() string

func (Workshop) UpdateViews

func (w Workshop) UpdateViews()

Jump to

Keyboard shortcuts

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