role

package
v0.0.0-...-0e3259e Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: MIT Imports: 6 Imported by: 3

Documentation

Overview

Package role menages datastore's role kind.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFindRole = errors.New("Error while getting role")
)

Errors

Functions

func Add

func Add(ctx context.Context, k *datastore.Key, r *Role) error

Add puts the role first and then creates and puts all the corresponding roleTypeRoles with role key as the parent key. Also returns an error.

func Delete

func Delete(ctx context.Context, ek string) error

Delete removes the entity and all the corresponding "roleTypeRole" and "roleUser" entities in a transaction by the provided encoded entity key and returns an error.

Types

type Role

type Role struct {
	ID        string    `datastore:"-"`
	ContextID string    `datastore:"-" json:"contextID"`
	RoleTypes []string  `datastore:"-" json:"-"`
	Created   time.Time `json:"-"`
}

Role represents user roles. Key's stringID is encoded "Context" key. And the "ContextID" is an encoded "Context" key for multilang usage purpose.

type Roles

type Roles map[string]*Role

Roles is a map of role pointers with role IDs as their keys.

func GetAll

func GetAll(ctx context.Context) (Roles, error)

GetAll returns all the entities in an order(-Created) and an error.

Jump to

Keyboard shortcuts

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