comments

package
v0.0.0-...-b84af7b Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommentNotFound = errors.New("Comment has not been found by given criteria.")

Functions

func Delete

func Delete(deps Deps, c Comment) error

Delete comment.

func DeletePostComments

func DeletePostComments(deps Deps, postID bson.ObjectId) error

func FetchCount

func FetchCount(d Deps, query common.Query) (c int, err error)

func Post

func Post(id bson.ObjectId, limit, offset int, reverse bool, before *bson.ObjectId, after *bson.ObjectId) common.Query

func User

func User(id bson.ObjectId, limit, offset int) common.Query

Types

type Comment

type Comment struct {
	Id        bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	UserId    bson.ObjectId `bson:"user_id" json:"user_id"`
	PostId    bson.ObjectId `bson:"post_id,omitempty" json:"post_id,omitempty"`
	Votes     votes.Votes   `bson:"votes" json:"votes"`
	User      interface{}   `bson:"-" json:"author,omitempty"`
	Position  int           `bson:"position" json:"-"`
	Liked     int           `bson:"-" json:"liked,omitempty"`
	Content   string        `bson:"content" json:"content"`
	ReplyTo   bson.ObjectId `bson:"reply_to,omitempty" json:"reply_to,omitempty"`
	ReplyType string        `bson:"reply_type,omitempty" json:"reply_type,omitempty"`
	Chosen    bool          `bson:"chosen,omitempty" json:"chosen,omitempty"`
	Created   time.Time     `bson:"created_at" json:"created_at"`
	Updated   time.Time     `bson:"updated_at" json:"updated_at"`
	Deleted   *time.Time    `bson:"deleted_at,omitempty" json:"-"`

	// Runtime generated fields.
	Replies interface{} `bson:"-" json:"replies,omitempty"`
}

func FindId

func FindId(deps Deps, id bson.ObjectId) (comment Comment, err error)

func UpsertComment

func UpsertComment(deps Deps, c Comment) (comment Comment, err error)

UpsertComment performs validations before upserting data struct

func (Comment) GetContent

func (c Comment) GetContent() string

func (Comment) GetParseableMeta

func (c Comment) GetParseableMeta() map[string]interface{}

func (Comment) RelatedID

func (c Comment) RelatedID() bson.ObjectId

func (Comment) RelatedPost

func (c Comment) RelatedPost() bson.ObjectId

func (Comment) UpdateContent

func (c Comment) UpdateContent(content string) content.Parseable

func (Comment) VotableID

func (c Comment) VotableID() bson.ObjectId

func (Comment) VotableType

func (c Comment) VotableType() string

type Comments

type Comments []Comment

func FindList

func FindList(deps Deps, scopes ...common.Scope) (list Comments, err error)

func (Comments) IDList

func (all Comments) IDList() []bson.ObjectId

func (Comments) Map

func (all Comments) Map() map[bson.ObjectId]Comment

func (Comments) NestedIDList

func (all Comments) NestedIDList() (list []bson.ObjectId)

func (Comments) PostIDs

func (all Comments) PostIDs() []bson.ObjectId

func (Comments) PostsScope

func (all Comments) PostsScope() common.Scope

func (Comments) StrMap

func (all Comments) StrMap() map[string]Comment

func (Comments) UsersScope

func (all Comments) UsersScope() common.Scope

func (Comments) VotesOf

func (all Comments) VotesOf(deps Deps, userID bson.ObjectId) (list votes.List, err error)

VotesOf userId in comments resultset.

func (Comments) WithReplies

func (all Comments) WithReplies(deps Deps, max int) (Comments, error)

func (Comments) WithUsers

func (all Comments) WithUsers(deps Deps) (Comments, error)

WithUsers nested data loaded.

type CommentsSet

type CommentsSet struct {
	List  Comments `json:"list"`
	Count int      `json:"count"`
}

func FetchBy

func FetchBy(deps Deps, query common.Query) (CommentsSet, error)

type Deps

type Deps interface {
	Mgo() *mgo.Database
	S3() *s3.Bucket
	LedisDB() *ledis.DB
}

type Replies

type Replies struct {
	Id    bson.ObjectId `bson:"_id,omitempty" json:"-"`
	Count int           `bson:"count" json:"count"`
	List  Comments      `bson:"list" json:"list"`
}

func FindReplies

func FindReplies(deps Deps, list Comments, max int) (lists []Replies, err error)

type RepliesList

type RepliesList []Replies

Jump to

Keyboard shortcuts

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