comments

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2018 License: MIT Imports: 6 Imported by: 8

Documentation

Overview

Package comments represents the comment resource

Index

Constants

View Source
const (
	// TableName is the database table for this resource
	TableName = "comments"
	// KeyName is the primary key value for this resource
	KeyName = "id"
	// Order defines the default sort order in sql for this resource
	Order = "rank desc, points desc, id desc"
)

Variables

This section is empty.

Functions

func AllowedParams

func AllowedParams() []string

AllowedParams returns an array of allowed param keys for Update and Create.

func AllowedParamsAdmin

func AllowedParamsAdmin() []string

AllowedParamsAdmin returns an array of allowed param keys for Update and Create.

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 with a default order.

func Where

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

Where returns a new query for comments with the format and arguments supplied.

Types

type Comment

type Comment struct {
	// resource.Base defines behaviour and fields shared between all resources
	resource.Base

	// status.ResourceStatus defines a status field and associated behaviour
	status.ResourceStatus

	DottedIDs string
	ParentID  int64
	Children  []*Comment

	Points    int64
	Rank      int64
	StoryID   int64
	StoryName string
	Text      string
	UserID    int64
	UserName  string
}

Comment handles saving and retreiving comments from the database

func Find

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

Find fetches a single comment record from the database by id.

func FindAll

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

FindAll returns all results for this query

func FindFirst added in v1.0.1

func FindFirst(format string, args ...interface{}) (*Comment, error)

FindFirst fetches a single comment record from the database using a where query with the format and args provided.

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 (c *Comment) Destroy() error

Destroy removes the record from the database

func (*Comment) Editable

func (c *Comment) Editable() bool

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

func (*Comment) Level

func (c *Comment) Level() int64

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

func (*Comment) NegativePoints

func (c *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 (c *Comment) OwnedBy(uid int64) bool

OwnedBy returns true if this user id owns this comment.

func (*Comment) Root

func (c *Comment) Root() bool

Root returns true if this is a root comment

func (*Comment) StoryURL added in v1.0.1

func (c *Comment) StoryURL() string

StoryURL returns the internal resource URL for our story

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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