Documentation ¶
Overview ¶
Package users represents the user resource
Index ¶
- Constants
- func Admins() *query.Query
- func AllowedParams() []string
- func AllowedParamsAdmin() []string
- func Editors() *query.Query
- func Published() *query.Query
- func Query() *query.Query
- func Readers() *query.Query
- func Subscribed() *query.Query
- func Where(format string, args ...interface{}) *query.Query
- type User
- func (u *User) Admin() bool
- func (u *User) Anon() bool
- func (u *User) CanComment() bool
- func (u *User) CanDownvote() bool
- func (u *User) CanFlag() bool
- func (u *User) CanStyle() bool
- func (u *User) CanSubmit() bool
- func (u *User) CanUpvote() bool
- func (u *User) OwnedBy(uid int64) bool
- func (u *User) Reader() bool
- func (u *User) RoleDisplay() string
- func (u *User) RoleID() int64
- func (u *User) RoleOptions() []helpers.Option
- func (u *User) UserID() int64
Constants ¶
const ( // TableName is the database table for this resource TableName = "users" // KeyName is the primary key value for this resource KeyName = "id" // Order defines the default sort order in sql for this resource Order = "id asc" )
const ( Anon = 0 Editor = 10 Reader = 20 Admin = 100 )
User roles
Variables ¶
This section is empty.
Functions ¶
func AllowedParams ¶
func AllowedParams() []string
AllowedParams returns an array of acceptable params in update
func AllowedParamsAdmin ¶
func AllowedParamsAdmin() []string
AllowedParamsAdmin returns the cols editable by admins
func Subscribed ¶
Subscribed returns a query for all users with subscription = True.
Types ¶
type User ¶
type User struct { // resource.Base defines behaviour and fields shared between all resources resource.Base // status.ResourceStatus defines a status field and associated behaviour status.ResourceStatus Email string Name string Points int64 Role int64 Summary string Text string Title string Notification bool Subscription bool Plan string PasswordHash string PasswordResetAt time.Time }
User handles saving and retrieving users from the database
func FindFirst ¶
FindFirst fetches a single user record from the database using a where query with the format and args provided.
func NewWithColumns ¶
NewWithColumns creates a new user instance and fills it with data from the database cols provided.
func (*User) CanComment ¶
CanComment returns true if this user can comment.
func (*User) CanDownvote ¶
CanDownvote returns true if this user can downvote.
func (*User) RoleDisplay ¶
RoleDisplay returns the string representation of the Role status
func (*User) RoleOptions ¶
RoleOptions returns an array of Role values for this model (embedders may override this and roledisplay to extend)