users

package
v0.0.0-...-22be18f Latest Latest
Warning

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

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

Documentation

Overview

Package users represents the user resource

Index

Constants

View Source
const (
	RoleAdmin    = 100
	RoleCustomer = 1
)

Roles for users

Variables

This section is empty.

Functions

func AllowedParams

func AllowedParams() []string

AllowedParams returns an array of allowed param keys

func AllowedParamsCustomer

func AllowedParamsCustomer() []string

AllowedParamsCustomer returns an array of params that customers can edit on their user

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 users with status >= published

func Query

func Query() *query.Query

Query returns a new query for users

func Where

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

Where returns a Where query for users with the arguments supplied

Types

type User

type User struct {
	model.Model
	status.ModelStatus
	Email    string
	Key      string
	Name     string
	Password string
	Role     int64
	Summary  string
}

User handles saving and retreiving users from the database

func Find

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

Find returns a single record by id

func FindAll

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

FindAll returns all results for this query

func FindFirst

func FindFirst(q *query.Query) (*User, error)

FindFirst fetches the first result for this query

func FindName

func FindName(name string) (*User, error)

FindName returns a single record by name

func New

func New() *User

New creates and initialises a new user instance

func NewWithColumns

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

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

func (*User) Admin

func (m *User) Admin() bool

Admin returns true for admin users

func (*User) Anon

func (m *User) Anon() bool

Anon returns true if this user is not logged in

func (*User) Customer

func (m *User) Customer() bool

Customer returns true for customers signed in

func (*User) Destroy

func (m *User) Destroy() error

Destroy removes the record from the database

func (*User) IsUser

func (m *User) IsUser(u *User) bool

IsUser return true if the user given is this user

func (*User) OwnedBy

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

OwnedBy returns true if the user id passed in owns this model

func (*User) Update

func (m *User) 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