store

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2014 License: GPL-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DB Global DB object
	DB rh.DB

	// Classes     ClassStore
	Enrollments EnrollmentStore

	Classes          = DB.NewCollection("classes")
	Terms            = DB.NewCollection("terms")
	EnrollmentH      = DB.NewCollection("enrollments")
	People           = DB.NewCollection("people")
	UserH            = DB.NewCollection("users")
	AssignmentH      = DB.NewCollection("assignments")
	AssignmentGrades = DB.NewCollection("grades")

	Assignments     AssignmentStore
	AssignmentTypes AssignmentTypeStore

	Sessions SessionStore
	Users    UserStore

	// Errors
	ErrNotFound   = errors.New("record not found")
	ErrValidation = errors.New("validation error")
)
View Source
var (
	//ErrUserOrPasswdIncorrect err for password incorrect
	ErrUserOrPasswdIncorrect = errors.New("Email or password incorrect.")

	//ErrUserAlreadyExists err for duplicate user
	ErrUserAlreadyExists = errors.New("User with email already exists.")
	//ErrUserForPersonExists err for duplicate person
	ErrUserForPersonExists = errors.New("User for person already exists.")

	//ErrUserPasswordRequired err for trying to save without a password.
	// TODO: Remove this after refactoring.
	ErrUserPasswordRequired = errors.New("Password is required")
)

Functions

func Connect

func Connect(address, database string) error

Connect establishes connection with rethinkDB

func GetUserByID

func GetUserByID(id string) (m.User, error)

GetUserByID get a user by a ID.

func SetupDB

func SetupDB(bootstrap, testData bool)

SetupDB will be used to bootstrap the DB

Types

type AssignmentStore

type AssignmentStore struct {
	DefaultStore
}

func NewAssignmentStore

func NewAssignmentStore() AssignmentStore

func (*AssignmentStore) BeforeSave

func (a *AssignmentStore) BeforeSave(v *m.Assignment) error

BeforeSave ...

func (AssignmentStore) Store

func (a AssignmentStore) Store(v *m.Assignment) (string, error)

type AssignmentTypeStore

type AssignmentTypeStore struct {
	DefaultStore
}

func NewAssignmentTypeStore

func NewAssignmentTypeStore() AssignmentTypeStore

type DefaultStore

type DefaultStore struct {
	TableName string
}

DefaultStore ...

func NewDefaultStore

func NewDefaultStore(tableName string) DefaultStore

NewDefaultStore ...

func (DefaultStore) Delete

func (d DefaultStore) Delete(id string) error

Delete ...

func (*DefaultStore) Filter

func (d *DefaultStore) Filter(data interface{}, filter interface{}) error

func (DefaultStore) FindAll

func (d DefaultStore) FindAll(data interface{}) error

FindAll ...

func (DefaultStore) FindByID

func (d DefaultStore) FindByID(data m.Model, id string) error

FindByID ...

func (*DefaultStore) Store

func (d *DefaultStore) Store(v m.Model) (string, error)

Store ...

func (*DefaultStore) Update

func (d *DefaultStore) Update(v m.Model, id string) error

Update ...

type EnrollmentStore

type EnrollmentStore struct {
	DefaultStore
}

func NewEnrollmentStore

func NewEnrollmentStore() EnrollmentStore

func (EnrollmentStore) Filter

func (pr EnrollmentStore) Filter(enrollments *[]m.EnrollmentAPIRes, filter interface{}) error

type SessionStore

type SessionStore struct {
	DefaultStore
}

func NewSessionStore

func NewSessionStore() SessionStore

type Storer

type Storer interface {
	Store(m.Model) (string, error)
	Update(m.Model, string) error
	FindAll(interface{}) error
	FindByID(m.Model, string) error
}

Storer interface

type UserStore

type UserStore struct {
	DefaultStore
}

UserStore used to interact with db users

func NewUserStore

func NewUserStore() UserStore

NewUserStore returns a UserStore.

func (*UserStore) FindByEmail

func (us *UserStore) FindByEmail(email string) (m.User, error)

FindByEmail finds a single user that matches an email.

func (*UserStore) Store

func (us *UserStore) Store(u *m.User) error

Store saves a user into the db

Jump to

Keyboard shortcuts

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