users

package
v0.0.0-...-a17a3e0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2017 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Resource = store.Resource("users")

Resource is the name of the Resource for users.

Variables

View Source
var UserBucket = []byte("users")

Functions

func AddCoin

func AddCoin(u *User, coin int64) store.Mutation

AddCoin returns a store.Mutation which adds the given amount of coin to the given user. It presumes the user already exists in the DB and has a valid Name set. It sets the given User's Coin to the new value in the DB.

func AllUsers

func AllUsers(g Group) map[string]bool

AllUsers gets a map of all users in the Group.

func CheckNotExist

func CheckNotExist(names ...string) func(*bolt.Tx) error

func CheckUsersExist

func CheckUsersExist(names ...string) func(*bolt.Tx) error

CheckUsersExist checks that the Users with the given names exist.

func Create

func Create(u *User) func(*bolt.Tx) error

Create returns a writing transaction which checks that the user has not yet been created, then Puts its JSON representation in UserBucket.

func Delete

func Delete(userID string) store.Mutation

func DiffGroups

func DiffGroups(old, new Group) map[string]bool

DiffGroups returns a bool map where removed users' names are keys to false values, and added or retained users' names are keys to true values. It is assumed all Writers are also Readers and the Owner is unchanged.

func IsExists

func IsExists(err error) bool

func IsMissing

func IsMissing(err error) bool

func ValidateNew

func ValidateNew(u *User) error

ValidateNew validates a new User.

Types

type ByOwner

type ByOwner string

ByOwner is a Filter for Groups that have the given owner.

func (ByOwner) Member

func (b ByOwner) Member(s Group) bool

Member implements Filter on ByOwner.

type ByReader

type ByReader string

ByReader is a Filter for Groups that have the given read user.

func (ByReader) Member

func (b ByReader) Member(s Group) bool

Member implements Filter on ByReader.

type ByWriter

type ByWriter string

ByWriter is a Filter for Groups that have the given read user.

func (ByWriter) Member

func (b ByWriter) Member(s Group) bool

Member implements Filter on ByWriter.

type ErrExists

type ErrExists string

func (ErrExists) Error

func (e ErrExists) Error() string

type ErrMissing

type ErrMissing string

func (ErrMissing) Error

func (e ErrMissing) Error() string

type Filter

type Filter interface {
	Member(Group) bool
}

Filter determines Group membership.

type Group

type Group struct {
	Owner string `json:"owner"`

	Readers map[string]bool `json:"readers"`
	Writers map[string]bool `json:"writers"`
}

Group is a set of users which have different membership levels.

type MultiAnd

type MultiAnd []Filter

MultiAnd applies multiple Filters which all must be true.

func (MultiAnd) Member

func (m MultiAnd) Member(s Group) bool

Member implements Filter on MultiAnd.

type MultiOr

type MultiOr []Filter

MultiOr applies multiple Filters, any of which may be true.

func (MultiOr) Member

func (m MultiOr) Member(s Group) bool

Member implements Filter on MultiOr.

type User

type User struct {
	Name string `json:"name,omitempty"`
	Coin int64  `json:"coin"`
}

func (*User) Resource

func (u *User) Resource() store.Resource

Resource implements store.Resourcer on *User.

type Users

type Users []User

func (*Users) GetAll

func (u *Users) GetAll(tx *bolt.Tx) error

Jump to

Keyboard shortcuts

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