database

package
v0.0.0-...-f3557e7 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDatabaseSqlite = "file::memory:?cache=shared"
)

Variables

This section is empty.

Functions

func ActiveCategories

func ActiveCategories(category *Category) bool

func ActiveRoles

func ActiveRoles(role *Role) bool

func ActiveUsers

func ActiveUsers(user *User) bool

func ActiveVentures

func ActiveVentures(venture *Venture) bool

func AllCategories

func AllCategories(*Category) bool

func AllFeatureRoles

func AllFeatureRoles(*FeatureRole) bool

func AllFeatures

func AllFeatures(*Feature) bool

func AllRESTfulFeatures

func AllRESTfulFeatures(feature string) []string

func AllRoles

func AllRoles(*Role) bool

func AllUserRoles

func AllUserRoles(userRole *UserRole) bool

func AllUsers

func AllUsers(*User) bool

func AllVentures

func AllVentures(*Venture) bool

func CommitOnSuccess

func CommitOnSuccess(ops Operations, success *bool, afterCommit func())

func EnsureFeatures

func EnsureFeatures(names []string) (err error)

func FeatureDELETE

func FeatureDELETE(feature string) string

func FeatureGET

func FeatureGET(feature string) string

func FeaturePOST

func FeaturePOST(feature string) string

func FeaturePUT

func FeaturePUT(feature string) string

func IsAdmin

func IsAdmin(ops Operations, id int64) bool

func RESTfulFeatures

func RESTfulFeatures(feature string, methods ...string) []string

func UserRolesByUser

func UserRolesByUser(userId int64) func(*UserRole) bool

func UserRolesByUserAndRole

func UserRolesByUserAndRole(userId, roleId int64) func(*UserRole) bool

Types

type AccessBackend

type AccessBackend struct {
	// contains filtered or unexported fields
}

func NewAccessBackend

func NewAccessBackend() *AccessBackend

func (*AccessBackend) Invalidate

func (ab *AccessBackend) Invalidate()

func (*AccessBackend) UserAllowed

func (ab *AccessBackend) UserAllowed(userId int64, feature string) (bool, error)

func (*AccessBackend) UserVentureAllowed

func (ab *AccessBackend) UserVentureAllowed(userId, ventureId int64, feature string) (bool, error)

type Category

type Category struct {
	Id          int64
	Parent      sql.NullInt64
	Owner       sql.NullInt64
	Name        string
	Description string
	Active      bool
}

type Database

type Database interface {
	GetOperations() Operations
	Close() error
}
var Backend Database

type Entry

type Entry struct {
	Id          int64
	UserId      int64
	VentureId   int64
	CategoryId  int64
	StartTime   time.Time
	Duration    time.Duration
	Chargeable  sql.NullBool
	Description sql.NullString
}

type Feature

type Feature struct {
	Id   int64
	Name string
}

type FeatureRole

type FeatureRole struct {
	Id        int64
	FeatureId int64
	RoleId    int64
}

type Operations

type Operations interface {
	Begin() error
	Commit() error
	Rollback() error

	CreateUser(*User) error
	UpdateUser(*User) error

	GetUsers(func(*User) bool) ([]*User, error)
	GetUserById(int64) (*User, error)
	GetUserByInitals(string) (*User, error)

	CreateRole(*Role) error
	GetRoleById(int64) (*Role, error)
	UpdateRole(*Role) error
	GetRoles(func(*Role) bool) ([]*Role, error)

	CreateVenture(*Venture) error
	GetVentureById(int64) (*Venture, error)
	UpdateVenture(*Venture) error
	GetVentures(func(*Venture) bool) ([]*Venture, error)

	AddUserRoleToVenture(*UserRole, sql.NullInt64) error
	RemoveUserRoleFromVenture(int64) error
	GetVentureUserRoles(func(*UserRole) bool, sql.NullInt64) ([]*UserRole, error)

	CreateCategory(*Category) error
	UpdateCategory(*Category) error
	GetCategoryById(id int64) (*Category, error)
	GetCategories(func(*Category) bool) ([]*Category, error)

	CreateEntry(*Entry) error
	UpdateEntry(*Entry) error
	DeleteEntry(int64) error

	GetEntryById(int64) (*Entry, error)
	GetEntriesByUserId(int64) ([]*Entry, error)
	GetEntriesByVentureId(int64) ([]*Entry, error)

	CreateFeature(*Feature) error
	UpdateFeature(*Feature) error
	DeleteFeature(int64) error
	GetFeatures(func(*Feature) bool) ([]*Feature, error)
	GetFeatureById(int64) (*Feature, error)
	GetFeatureByName(string) (*Feature, error)

	CreateFeatureRole(*FeatureRole) error
	UpdateFeatureRole(*FeatureRole) error
	DeleteFeatureRole(int64) error
	GetFeatureRoles(func(*FeatureRole) bool) ([]*FeatureRole, error)
	GetFeatureRolesByRole(func(*FeatureRole) bool, int64) ([]*FeatureRole, error)
	GetFeatureRoleById(int64) (*FeatureRole, error)
}

type PGDatabase

type PGDatabase struct {
	// contains filtered or unexported fields
}

func NewPGDatabase

func NewPGDatabase(dataSourceName, admPW string) (*PGDatabase, error)

func (*PGDatabase) Close

func (sdb *PGDatabase) Close() error

func (*PGDatabase) GetOperations

func (sdb *PGDatabase) GetOperations() Operations

type Role

type Role struct {
	Id          int64
	Parent      sql.NullInt64
	Name        string
	Description string
	Active      bool
}

type SQLiteDatabase

type SQLiteDatabase struct {
	// contains filtered or unexported fields
}

func NewSQLiteDatabase

func NewSQLiteDatabase(dataSourceName, admPW string) (*SQLiteDatabase, error)

func (*SQLiteDatabase) Close

func (sdb *SQLiteDatabase) Close() error

func (*SQLiteDatabase) GetOperations

func (sdb *SQLiteDatabase) GetOperations() Operations

type User

type User struct {
	Id       int64
	Forename string
	Surname  string
	Initials string
	Active   bool
	Admin    bool
	Secret   []byte
}

type UserRole

type UserRole struct {
	Id     int64
	UserId int64
	RoleId int64
}

type Venture

type Venture struct {
	Id          int64
	Name        string
	Description string
	Active      bool
}

Jump to

Keyboard shortcuts

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