database

package
v0.2.0-DEV Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DFMT = "2006-01-02"

Variables

View Source
var DStamp = time.Now().UTC().Format(DFMT)

Functions

func AddGroups

func AddGroups(gs []string) error

func AddPassword

func AddPassword(us string, pw string) error

func AddUsers

func AddUsers(us []string)

func AddUsersToGroups

func AddUsersToGroups(gs []string, us []string) error

func AuthUser

func AuthUser(us string, p string, r *http.Request) bool

func BucketList

func BucketList(p string) []string

There is no way with storm to get a list of all buckets. This uses a direct Bolt view to get the list

func CloseInstance

func CloseInstance()

func DateBucket

func DateBucket(p string, d string) storm.Node

func DelGroups

func DelGroups(gs []string) error

func DelStatus

func DelStatus(sT StatusS)

func DelUsers

func DelUsers(us []string)

func DelUsersFromGroups

func DelUsersFromGroups(gs []string, us []string) error

func Find

func Find(field string, value interface{}, to interface{}) error

func GetAll

func GetAll(d interface{}) error

func GetAllByIndex

func GetAllByIndex(field string, d interface{}) error

func GetAllStatusBuckets

func GetAllStatusBuckets() []string

func InitStatus

func InitStatus()

func IsAdmin

func IsAdmin(user string) bool

func IsSelf

func IsSelf(me, user string) bool

func ModifyGroups

func ModifyGroups(gs []GroupS) error

func One

func One(field string, value interface{}, to interface{}) error

func UserInGroup

func UserInGroup(g GroupS, u UserS) bool

Types

type DataS

type DataS interface {
	Save() error
	Delete() error
	Update() error
	Compare(DataS) bool
}

type Database

type Database struct {
	Db    string
	DbObj *storm.DB
}

func GetInstance

func GetInstance() *Database

func (*Database) Close

func (d *Database) Close()

func (*Database) Open

func (d *Database) Open()

type GroupS

type GroupS struct {
	ID      int     `json:"id"`
	Name    string  `json:"name" storm:"index,unique"`
	Members []UserS `json:"members,omitempty"`
}

func GetGroup

func GetGroup(n string) (GroupS, error)

func ListGroups

func ListGroups() ([]GroupS, error)

func RemoveGroup

func RemoveGroup(list []GroupS, rm GroupS) []GroupS

func (GroupS) Compare

func (s GroupS) Compare(d DataS) bool

func (GroupS) Delete

func (s GroupS) Delete() error

func (GroupS) Save

func (s GroupS) Save() error

func (GroupS) String

func (s GroupS) String() string

func (GroupS) Update

func (s GroupS) Update() error

type StatusS

type StatusS struct {
	ID     int    `json:"id"`
	Date   string `json:"date" storm:"index"`
	Status string `json:"status"`
	User   UserS  `json:"user" storm:"index"`
}

func GetAllStatusByDate

func GetAllStatusByDate(date string) ([]StatusS, error)

func GetStatus

func GetStatus(uS UserS, date string) []StatusS

func NewStatus

func NewStatus(uS UserS, s string) StatusS

func (*StatusS) Delete

func (s *StatusS) Delete() error

func (*StatusS) Save

func (s *StatusS) Save() error

func (*StatusS) String

func (s *StatusS) String() string

func (*StatusS) Update

func (s *StatusS) Update() error

type UserS

type UserS struct {
	ID       int    `json:"id"`
	Nick     string `json:"nick" storm:"index,unique"`
	Password string `json:"-"`
}

func GetUser

func GetUser(n string) (UserS, error)

func ListUsers

func ListUsers() []UserS

func RemoveUser

func RemoveUser(list []UserS, rm UserS) []UserS

func (UserS) Compare

func (s UserS) Compare(d DataS) bool

func (UserS) Delete

func (s UserS) Delete() error

func (UserS) Save

func (s UserS) Save() error

func (UserS) String

func (s UserS) String() string

func (UserS) Update

func (s UserS) Update() error

Jump to

Keyboard shortcuts

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