Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Comment ¶
type Comment struct { ID primitive.ObjectID `bson:"_id"` //comment id Parent primitive.ObjectID `bson:"parent" json:"parent"` //parent comment id, reply comment SourceID SourceID `bson:"source_id" json:"source_id"` //comment source id Content string `bson:"content" json:"content"` //comment content Grade float32 `bson:"grade" json:"grade"` //source grade .5 - 5 Ctime time.Time `bson:"c_time" json:"c_time"` //create time Utime time.Time `bson:"u_time" json:"u_time"` //update time User `bson:",inline" json:",inline"` }
Comment mongo fields
type CommentStatistics ¶
CommentStatistics statistics comments
type Dao ¶
type Dao interface { AddComment(*Comment) bool GetComments(s SourceID, offset, limit int64) []*Comment Aggregate(s SourceID) *CommentStatistics }
Dao comment db
type MongoService ¶
type MongoService struct {
// contains filtered or unexported fields
}
MongoService the db service
func NewMongo ¶
func NewMongo(cfg *config.Config) *MongoService
NewMongo return a new mongodb connect service
func (*MongoService) AddComment ¶
func (m *MongoService) AddComment(c *Comment) bool
AddComment add comment to mongodb
func (*MongoService) Aggregate ¶
func (m *MongoService) Aggregate(s SourceID) *CommentStatistics
Aggregate all comments count and average score
func (*MongoService) GetComments ¶
func (m *MongoService) GetComments(s SourceID, offset, limit int64) []*Comment
GetComments get comments by sourceid
Click to show internal directories.
Click to hide internal directories.