comments

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package comments represents the comment resource

Index

Constants

View Source
const RankOrder = "points desc, id desc"

RankOrder orders comments by points then created at

Variables

This section is empty.

Functions

func AllowedParams

func AllowedParams() []string

AllowedParams returns an array of allowed param keys

func AllowedParamsAdmin

func AllowedParamsAdmin() []string

AllowedParamsAdmin returns an array of allowed param keys

func Create

func Create(params map[string]string) (int64, error)

Create inserts a new record in the database using params, and returns the newly created id

func Published

func Published() *query.Query

Published returns a query for all comments with status >= published

func Query

func Query() *query.Query

Query returns a new query for comments

func Where

func Where(format string, args ...interface{}) *query.Query

Where returns a Where query for comments with the arguments supplied

Types

type Comment

type Comment struct {
	model.Model
	status.ModelStatus
	Text string

	Points int64
	Rank   int64

	// Comment tree
	ParentId  int64
	DottedIds string
	Children  []*Comment

	//Join ids
	UserId  int64
	StoryId int64

	// Denormalised join details, for quick display, alternatively could use joins
	UserName  string
	StoryName string
}

Comment handles saving and retreiving comments from the database

func Find

func Find(id int64) (*Comment, error)

Find returns a single record by id in params

func FindAll

func FindAll(q *query.Query) ([]*Comment, error)

FindAll returns all results for this query

func New

func New() *Comment

New creates and initialises a new comment instance

func NewWithColumns

func NewWithColumns(cols map[string]interface{}) *Comment

NewWithColumns creates a new comment instance and fills it with data from the database cols provided

func (*Comment) Destroy

func (m *Comment) Destroy() error

Destroy removes the record from the database

func (*Comment) Editable

func (m *Comment) Editable() bool

Editable returns true if this comment is editable. Comments are editable if less than 3 hours old.

func (*Comment) Level

func (m *Comment) Level() int64

Level returns the nesting level of this comment, based on dotted_ids

func (*Comment) NegativePoints

func (m *Comment) NegativePoints() int64

NegativePoints returns a negative point score between 0 and 5 (positive points return 0, below -6 returns 6)

func (*Comment) OwnedBy

func (m *Comment) OwnedBy(uid int64) bool

OwnedBy returns true if this user id owns this comment.

func (*Comment) Root

func (m *Comment) Root() bool

Root returns true if this is a root comment

func (*Comment) URLStory

func (m *Comment) URLStory() string

URLStory returns the internal resource URL for our story

func (*Comment) Update

func (m *Comment) Update(params map[string]string) error

Update sets the record in the database from params

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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