model

package
v0.0.0-...-291b6b4 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Beforecare = 5 * iota
	Aftercare
	Both
)

Variables

View Source
var (
	// ErrCode is a config or an internal error
	ErrCode = errors.New("Case statement in code is not correct.")
	// ErrNoResult is a not results error
	ErrNoResult = errors.New("Result not found.")
	//ErrNoSuchStudent is there is no such student
	ErrNoSuchStudent = errors.New("Try a valid student ID please.")
	// ErrUnavailable is a database not available error
	ErrUnavailable = errors.New("Database is unavailable.")
	// ErrUnauthorized is a permissions violation
	ErrUnauthorized = errors.New("User does not have permission to perform this operation.")
)

Functions

func ClockinCreate

func ClockinCreate(student_id string) error

ClockinCreate creates a clockin

func ClockinDeleteByID

func ClockinDeleteByID(clockinID string) error

ClockinDelete deletes a note Also add an admin checking for delete functionality

func NoteCreate

func NoteCreate(content string, userID string) error

NoteCreate creates a note

func NoteDelete

func NoteDelete(userID string, noteID string) error

NoteDelete deletes a note

func NoteUpdate

func NoteUpdate(content string, userID string, noteID string) error

NoteUpdate updates a note

func StudentCreate

func StudentCreate(first_name, last_name, grade, escaped_student_id string,
	balance float64, caretype int64, fivedays, freereduced bool) error

StudentCreate creates student

func StudentDelete

func StudentDelete(studentID string) error

StudentDelete deletes a student

func StudentUpdate

func StudentUpdate(studentID, firstName, lastName, grade string) error

StudentUpdate updates a student

func UserCreate

func UserCreate(first_name, last_name, email, password string) error

UserCreate creates user

Types

type Clockin

type Clockin struct {
	ObjectID  bson.ObjectId `bson:"_id"`
	StudentID string        `bson:"student_id"`
	InAt      int64         `db:"in_at"  bson:"in_at"`
	OutAt     int64         `db:"out_at" bson:"out_at"`
	TotalTime int64         `db:"total_time" bson:"total_time"`
	IsOut     bool          `db:"is_out" bson:"is_out"`
}

Note table contains the information for each note

func ClockinByID

func ClockinByID(clockinID string) (Clockin, error)

ClockinByID gets note by ID

func ClockinsByStudentID

func ClockinsByStudentID(student_id string) ([]Clockin, error)

ClockinsByStudentID gets all clockins for a student

func LastClockinByStudentID

func LastClockinByStudentID(student_id string) (Clockin, error)

LastClockinByStudentID gets the last clockin for a student

func (*Clockin) ClockinID

func (clockin *Clockin) ClockinID() string

ClockinID returns the clockin id

type Note

type Note struct {
	ObjectID  bson.ObjectId `bson:"_id"`
	ID        uint32        `db:"id" bson:"id,omitempty"` // Don't use Id, use NoteID() instead for consistency with MongoDB
	Content   string        `db:"content" bson:"content"`
	UserID    bson.ObjectId `bson:"user_id"`
	UID       uint32        `db:"user_id" bson:"userid,omitempty"`
	CreatedAt time.Time     `db:"created_at" bson:"created_at"`
	UpdatedAt time.Time     `db:"updated_at" bson:"updated_at"`
	Deleted   uint8         `db:"deleted" bson:"deleted"`
}

Note table contains the information for each note

func NoteByID

func NoteByID(userID string, noteID string) (Note, error)

NoteByID gets note by ID

func NotesByUserID

func NotesByUserID(userID string) ([]Note, error)

NotesByUserID gets all notes for a user

func (*Note) NoteID

func (u *Note) NoteID() string

NoteID returns the note id

type Student

type Student struct {
	ObjectId    bson.ObjectId `bson:"_id"`
	First_name  string        `db:"first_name"  bson:"first_name"`
	Last_name   string        `db:"last_name"   bson:"last_name"`
	Grade       string        `db:"grade"       bson:"grade"`
	Student_id  string        `db:"student_id"  bson:"student_id"`
	Created_at  time.Time     `db:"created_at"  bson:"created_at"`
	Updated_at  time.Time     `db:"updated_at"  bson:"updated_at"`
	Deleted     uint8         `db:"deleted"     bson:"deleted"`
	FiveDays    bool          `db:"fivedays"    bson:"fivedays"`
	CareType    int64         `db:"caretype"    bson:"caretype"`
	FreeReduced bool          `db:"freereduced" bson:"freereduced"`
	Balance     float64       `db:"balance"     bson:"balance"`
}

Student table contains the information for each student

func StudentBySID

func StudentBySID(sid string) (Student, error)

StudentBySID gets student information from student school id

func StudentsGet

func StudentsGet() ([]Student, error)

StudentsGet gets students

func (*Student) ID

func (s *Student) ID() string

Id returns the student id

func (*Student) SID

func (s *Student) SID() string

SID returns the student school id

type User

type User struct {
	ObjectId   bson.ObjectId `bson:"_id"`
	First_name string        `db:"first_name" bson:"first_name"`
	Last_name  string        `db:"last_name" bson:"last_name"`
	Email      string        `db:"email" bson:"email"`
	Password   string        `db:"password" bson:"password"`
	Status_id  uint8         `db:"status_id" bson:"status_id"`
	Created_at time.Time     `db:"created_at" bson:"created_at"`
	Updated_at time.Time     `db:"updated_at" bson:"updated_at"`
	Deleted    uint8         `db:"deleted" bson:"deleted"`
}

User table contains the information for each user

func UserByEmail

func UserByEmail(email string) (User, error)

UserByEmail gets user information from email

func (*User) ID

func (u *User) ID() string

Id returns the user id

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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