models

package
v0.0.0-...-4c788e1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEvent

func AddEvent(newEvent *Event) error

AddEvent adds a new event into the db

func AddRegistration

func AddRegistration(r *Registration) error

AddRegistration adds a registration into the db

func AddUser

func AddUser(u *User) error

AddUser adds a new user after registration into the db

func CancelRegistration

func CancelRegistration(r Registration) (bool, error)

CancelRegistration cancels a registration of an event

func CheckIfUserRegisteredForEvent

func CheckIfUserRegisteredForEvent(userID, eventID int) (bool, error)

CheckIfUserRegisteredForEvent checks if the user registered for a particular event

func CheckIfUserRegisteredForEventByMongoID

func CheckIfUserRegisteredForEventByMongoID(mongoID string, eventID int) (bool, error)

CheckIfUserRegisteredForEventByMongoID checks if the user registered for the event using Mongo Object ID

func CheckUserHash

func CheckUserHash(email, password string) bool

CheckUserHash checks if the given combination of email and password exists in the db

func DeleteEvent

func DeleteEvent(eventID int) error

DeleteEvent deletes an events from the db

func Login

func Login(email, password string) (interface{}, error)

Login checks if a user combination is present in the database. If yes, returns the user object, or else returns a nil

func UpdateEvent

func UpdateEvent(updateEvent *Event) error

UpdateEvent updates an event in the db

Types

type Event

type Event struct {
	EventName   string `json:"name"`
	EventID     int    `bson:"id" json:"id"`
	Fee         int    `json:"fee"`
	TeamSize    int    `json:"teamsize"`
	Category    string `json:"category"`
	Day         int    `json:"day"`
	StartTime   int    `json:"start"`
	EndTime     int    `json:"end"`
	Description string `json:"description"`
	ImageUrl    string `json:"url"`
}

func FindAllEvents

func FindAllEvents() ([]Event, error)

FindAllEvents returns all events in the fest db

func FindEventByID

func FindEventByID(id int) (Event, error)

FindEventByID finds an event given its id

func GetEventsOfUser

func GetEventsOfUser(userID int) ([]Event, error)

GetEventsOfUser returns all the events registered by a user

type Registration

type Registration struct {
	EventID int    `bson:"eventid" json:"eventid"`
	UserID  int    `bson:"userid" json:"userid"`
	RegID   string `bson:"regid" json:"regid"`
}

Registration contains the record of user registered for a particular event

type User

type User struct {
	FirstName    string `bson:"fname" json:"fname"`
	LastName     string `bson:"lname" json:"lname"`
	Gender       string `bson:"gender" json:"gender"`
	PhoneNumber  string `bson:"number" json:"number"`
	EmailAddress string `bson:"email" json:"email"`
	CollegeName  string `bson:"college" json:"college"`
	Password     string `bson:"pwd" json:",omitempty"`
	UserID       int    `bson:"userid" json:"userid"`
	SamID        string `bson:"samid" json:"samid"`
}

User is the structure of how a User looks

func GetAllUsers

func GetAllUsers() ([]User, error)

GetAllUsers returns all the users registered for the fest

func GetUserByID

func GetUserByID(userID int) (User, error)

GetUserByID returns the users given the userid

func GetUsersForEvent

func GetUsersForEvent(eventID int) ([]User, error)

GetUsersForEvent returns all the users registered for a single event

Jump to

Keyboard shortcuts

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