Documentation
¶
Index ¶
- Variables
- func BBoltTransaction(db *bbolt.DB) buffalo.MiddlewareFunc
- func DBToJSON(w io.Writer) error
- type ByArchived
- type ByVotes
- type Categories
- type Category
- func (c *Category) AddSubscriber(id uuid.UUID)
- func (c *Category) RemoveSubscriber(id uuid.UUID)
- func (c Category) String() string
- func (c *Category) Validate(tx *pop.Connection) (*validate.Errors, error)
- func (c *Category) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)
- func (c *Category) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)
- type Evaluation
- type Evaluations
- type Forum
- func (f Forum) LogoImage(opt render.Data) template.HTML
- func (f Forum) String() string
- func (f *Forum) Validate(tx *pop.Connection) (*validate.Errors, error)
- func (f *Forum) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)
- func (f *Forum) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)
- type Forums
- type Replies
- type Reply
- type Submission
- type Submissions
- type Topic
- func (t *Topic) AddSubscriber(id uuid.UUID)
- func (t *Topic) AddVoter(id uuid.UUID)
- func (t Topic) Authors() Users
- func (t Topic) LastUpdate() time.Time
- func (t *Topic) RemoveSubscriber(id uuid.UUID)
- func (t *Topic) RemoveVoter(id uuid.UUID)
- func (t Topic) String() string
- func (t Topic) Subscribed(id uuid.UUID) bool
- func (t *Topic) Validate(tx *pop.Connection) (*validate.Errors, error)
- func (t Topic) Voted(id uuid.UUID) bool
- func (t Topic) Votes() int
- type Topics
- type User
- func (u *User) AddSubscription(id uuid.UUID)
- func (u User) Icon(label string) template.HTML
- func (u User) ImageSrc() string
- func (u User) IsAuthor(id uuid.UUID) bool
- func (u *User) RemoveSubscription(id uuid.UUID)
- func (u User) String() string
- func (u User) Subscribed(id uuid.UUID) bool
- func (u *User) Validate(tx *pop.Connection) (*validate.Errors, error)
- func (u *User) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)
- func (u *User) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)
- type Users
Constants ¶
This section is empty.
Variables ¶
var BDB *bbolt.DB
BDB is a transaction in the simple BBolt database for fulfilling database needs when a full blown SQL server is not required
var DB *pop.Connection
DB is a connection to your database to be used throughout your application.
Functions ¶
func BBoltTransaction ¶
func BBoltTransaction(db *bbolt.DB) buffalo.MiddlewareFunc
BBoltTransaction is a piece of Buffalo middleware that wraps each request in a BBoltDB transaction. The transaction will automatically get committed if there's no errors and the response status code is a 2xx or 3xx, otherwise it'll be rolled back. It will also add a field to the log, "bdb", that shows the total duration spent during the request writing + spilling + re-balancing. This function is nearly an identical copy of pop's Transaction() just adapted to BBolt. Databases should be defined/initialized in models/models.go One important thing to not is that a writable transaction locks the database to other writable transaction, which means only one transaction will be processed if there are multiple goroutines waiting to read/write as only ONE read/write tx can exist at a time. This may also not scale well if there are many random write operations happening in a single transaction. BBolt is more adept at small operations. see https://github.com/boltdb/bolt#caveats--limitations for more information.
Types ¶
type ByArchived ¶
type ByArchived []Topic
ByArchived slice of Topics. sorted by age. Archived topics last
func (ByArchived) Len ¶
func (t ByArchived) Len() int
func (ByArchived) Less ¶
func (t ByArchived) Less(i, j int) bool
func (ByArchived) Swap ¶
func (t ByArchived) Swap(i, j int)
type ByVotes ¶ added in v0.3.0
type ByVotes []Topic
ByVotes sorts primarily by archived, then by votes, lastly by creation date
type Categories ¶
type Categories []Category
Categories is not required by pop and may be deleted
func (Categories) Len ¶
func (c Categories) Len() int
func (Categories) Less ¶
func (c Categories) Less(i, j int) bool
func (Categories) String ¶
func (c Categories) String() string
String is not required by pop and may be deleted
func (Categories) Swap ¶
func (c Categories) Swap(i, j int)
type Category ¶
type Category struct { ID uuid.UUID `json:"id" db:"id"` Title string `json:"title" db:"title" form:"title"` Description nulls.String `json:"description" db:"description" form:"description"` Subscribers slices.UUID `json:"subscribers" db:"subscribers"` ParentCategory nulls.UUID `json:"parent_category" db:"parent_category"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
Category is used by pop to map your categories database table to your go code.
func (*Category) AddSubscriber ¶
AddSubscriber add a uuid to category.Subscribers
func (*Category) RemoveSubscriber ¶
RemoveSubscriber remove a uuid from category.Subscribers
func (*Category) Validate ¶
Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.
func (*Category) ValidateCreate ¶
ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.
func (*Category) ValidateUpdate ¶
ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.
type Evaluation ¶
type Evaluation struct { ID uuid.UUID `json:"id" db:"id"` Title string `json:"title" db:"title" form:"title"` Description string `json:"description" db:"description" form:"description"` Content string `json:"content" db:"content" form:"content"` Solution string `json:"solution" db:"solution" form:"solution"` Hidden bool `json:"hidden" db:"hidden" form:"hidden"` Deleted bool `json:"deleted" db:"deleted" form:"deleted"` Inputs nulls.String `json:"inputs" db:"inputs" form:"stdin"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
Evaluation is used by pop to map your evaluations database table to your go code.
func (Evaluation) String ¶
func (e Evaluation) String() string
String is not required by pop and may be deleted
func (*Evaluation) Validate ¶
func (e *Evaluation) Validate(tx *pop.Connection) (*validate.Errors, error)
Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.
type Evaluations ¶
type Evaluations []Evaluation
Evaluations is not required by pop and may be deleted
func (Evaluations) Len ¶
func (e Evaluations) Len() int
func (Evaluations) Less ¶
func (e Evaluations) Less(i, j int) bool
func (Evaluations) String ¶
func (e Evaluations) String() string
String is not required by pop and may be deleted
func (Evaluations) Swap ¶
func (e Evaluations) Swap(i, j int)
type Forum ¶
type Forum struct { ID uuid.UUID `json:"id" db:"id"` Title string `json:"title" db:"title" form:"title"` Description string `json:"description" db:"description" form:"description"` Logo []byte `json:"logo" db:"logo" form:"-"` Defcon string `json:"defcon" db:"defcon" form:"access"` // level of access needed to see forum Staff slices.UUID `json:"staff" db:"staff" form:"-"` // moderator IDs CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` StaffEmails string `form:"staffemail" db:"-"` }
Forum is used by pop to map your forums database table to your go code.
func (*Forum) Validate ¶
Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.
func (*Forum) ValidateCreate ¶
ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.
func (*Forum) ValidateUpdate ¶
ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.
type Replies ¶
type Replies []Reply
Replies and sort algorithm
type Reply ¶
type Reply struct { ID uuid.UUID `json:"id" db:"id"` AuthorID uuid.UUID `json:"author_id" db:"author_id"` TopicID uuid.UUID `json:"topic_id" db:"topic_id"` Content string `json:"content" db:"content" form:"content"` Deleted bool `json:"deleted" db:"deleted"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` Author *User `json:"-" db:"-"` Topic *Topic `json:"-" db:"-"` }
Reply is used by pop to map your replies database table to your go code.
type Submission ¶ added in v0.4.0
type Submission struct { ID uuid.UUID `json:"id" db:"id"` ForumID uuid.UUID `json:"forum_id" db:"forum_id"` IsTemplate bool `json:"is_template" db:"is_template"` UserID uuid.UUID `json:"user_id" db:"user_id"` RequireEmailVerify bool `json:"require_email_verify" db:"require_email_verify"` // Template fields (isTemplate == true) Title nulls.String `json:"title" db:"title"` Description nulls.String `json:"description" db:"description"` Schemas nulls.String `json:"schemas" db:"schemas"` Hidden bool `json:"hidden" db:"hidden"` Deleted bool `json:"deleted" db:"deleted"` Editable bool `json:"editable" db:"editable"` Anonymous bool `json:"anonymous" db:"anonymous"` // Response fields (isTemplate == false) SubmissionID uuid.NullUUID `json:"submission_id" db:"submission_id"` Response nulls.String `json:"response" db:"response"` HasAttachment bool `json:"has_attachment" db:"has_attachment"` Zip nulls.ByteSlice `json:"zip" db:"zip"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
Submission is used by pop to map your submissions database table to your go code. Submission is basically a google forms response or actual form template mockup
func (Submission) String ¶ added in v0.4.0
func (s Submission) String() string
String is not required by pop and may be deleted
func (*Submission) Validate ¶ added in v0.4.0
func (s *Submission) Validate(tx *pop.Connection) (*validate.Errors, error)
Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.
func (*Submission) ValidateCreate ¶ added in v0.4.0
func (s *Submission) ValidateCreate(tx *pop.Connection) (*validate.Errors, error)
ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.
func (*Submission) ValidateUpdate ¶ added in v0.4.0
func (s *Submission) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error)
ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.
type Submissions ¶ added in v0.4.0
type Submissions []Submission
Submissions is not required by pop and may be deleted
func (Submissions) String ¶ added in v0.4.0
func (s Submissions) String() string
String is not required by pop and may be deleted
type Topic ¶
type Topic struct { ID uuid.UUID `json:"id" db:"id"` Title string `json:"title" db:"title" form:"title"` Content string `json:"content" db:"content" form:"content"` AuthorID uuid.UUID `json:"author_id" db:"author_id"` CategoryID uuid.UUID `json:"category_id" db:"category_id" ` Voters slices.UUID `json:"voters" db:"voters"` Archived bool `jsonL:"archived" db:"archived" form:"archive"` Deleted bool `json:"deleted" db:"deleted"` Subscribers slices.UUID `json:"subscribers" db:"subscribers"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` Author *User `json:"-" db:"-"` Category *Category `json:"-" db:"-"` Replies Replies `json:"-" db:"-"` }
Topic is used by pop to map your topics database table to your go code.
func (*Topic) AddSubscriber ¶
AddSubscriber add id to topic.subscribers
func (Topic) Authors ¶
Authors returns a slice of users including the main topic author and also reply authors.
func (Topic) LastUpdate ¶
LastUpdate returns last time topic was edited, created or replied to
func (*Topic) RemoveSubscriber ¶
RemoveSubscriber remove subscriber from topic.Subscribers
func (*Topic) RemoveVoter ¶ added in v0.3.0
RemoveVoter remove subscriber from topic.Voters
func (Topic) Subscribed ¶
Subscribed checks if id in Topic.Subscribers
func (*Topic) Validate ¶
Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.
type Topics ¶
type Topics []Topic
Topics slice of Topics. sorted by age.
type User ¶
type User struct { ID uuid.UUID `json:"id" db:"id"` Name string `json:"name" db:"name"` Nick string `json:"nick" db:"nick" form:"nick"` Provider string `json:"provider" db:"provider"` ProviderID string `json:"provider_id" db:"provider_id"` Email string `json:"email" db:"email"` Role string `json:"role" db:"role"` AvatarURL string `json:"avatar" db:"avatar_url"` Subscriptions slices.UUID `json:"subscriptions" db:"subscriptions"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` Theme string `db:"-" json:"-" form:"code-theme"` }
User is used by pop to map your users database table to your go code.
func (*User) AddSubscription ¶
AddSubscription add uuid to user.Subscriptions
func (*User) RemoveSubscription ¶
RemoveSubscription safe way to update models.User Subscriptions.
func (User) Subscribed ¶
Subscribed returns true if id is in user.Subscriptions
func (*User) Validate ¶
Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method. This method is not required and may be deleted.
func (*User) ValidateCreate ¶
ValidateCreate gets run every time you call "pop.ValidateAndCreate" method. This method is not required and may be deleted.
func (*User) ValidateUpdate ¶
ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method. This method is not required and may be deleted.