models

package
v0.0.0-...-d78814b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pending  = "pending"
	Answered = "answered"
	Deleted  = "deleted"
)

Status options.

Variables

View Source
var DB *gorm.DB

DB is a reference to the parent app's gorm DB.

Functions

func UseDB

func UseDB(db *gorm.DB)

UseDB registers the DB from the root app.

Types

type Question

type Question struct {
	ID       int       `json:"id"`
	Name     string    `json:"name"`
	Email    string    `json:"email"`
	Question string    `json:"question"`
	Status   Status    `json:"status"`
	Created  time.Time `json:"created"`
	Updated  time.Time `json:"updated"`
}

Question is a question asked of the blog owner.

func AllQuestions

func AllQuestions() ([]*Question, error)

AllQuestions returns all the Questions.

func GetQuestion

func GetQuestion(id int) (*Question, error)

GetQuestion by its ID.

func Load

func Load(id int) (*Question, error)

Load an Question by its ID.

func NewQuestion

func NewQuestion() *Question

NewQuestion creates a blank Question with sensible defaults.

func PendingQuestions

func PendingQuestions(offset, limit int) ([]*Question, error)

PendingQuestions returns pending questions in order of recency.

func (*Question) Delete

func (ev *Question) Delete() error

Delete an Question.

func (*Question) ParseForm

func (ev *Question) ParseForm(r *http.Request)

ParseForm populates the Question from form values.

func (*Question) Save

func (ev *Question) Save() error

Save the Question.

func (*Question) Validate

func (ev *Question) Validate() error

Validate makes sure the required fields are all present.

type Status

type Status string

Status of a Question.

Jump to

Keyboard shortcuts

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