mongo

package
v0.0.0-...-62160e7 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommentCol    *mongo.Collection
	CmtClosureCol *mongo.Collection
)
View Source
var (
	Client *mongo.Client
	DB     *mongo.Database
)
View Source
var ArticleCollection *mongo.Collection

Functions

func CreateIndex

func CreateIndex(collection *mongo.Collection, field bson.M, needUnique bool) error

func Init

func Init()

func InitArticle

func InitArticle()

func InitComment

func InitComment()

Types

type Article

type Article struct {
	ArticleID string `bson:"article_id"`
	Content   string `bson:"content"`
}

Article 定义 article 数据结构

type Comment

type Comment struct {
	ArticleID  string        `bson:"article_id"`
	Content    string        `bson:"content"`
	Degree     int8          `bson:"degree"` //用以请求顶级评论,degree==1
	UserID     string        `bson:"user_id"`
	HashID     string        `bson:"hash_id"`
	ParentID   string        `bson:"parent_id"`
	CreateTime bson.DateTime `bson:"create_time"`
}

type CommentClosure

type CommentClosure struct {
	AncestorID   string `bson:"ancestor"`
	DescendantID string `bson:"descendant"`
	ArticleID    string `bson:"article_id"`
	Depth        int    `bson:"depth"`
}

type CommentItem

type CommentItem struct {
	ArticleID  string        `bson:"article_id"`
	Content    string        `bson:"content"`
	Degree     int8          `bson:"degree"`
	UserID     string        `bson:"user_id"`
	HashID     string        `bson:"hash_id"`
	CreateTime bson.DateTime `bson:"create_time"`
	ChildNum   int64         `bson:"child_num"`
	ParentUID  string        `bson:"parent_uid"` //@xxx reply_to @xxx
}

CommentItem 用以请求comment list

Jump to

Keyboard shortcuts

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