Documentation
¶
Index ¶
- func ToInterfaceArray(s interface{}) []interface{}
- type ElectionDatabase
- func (db ElectionDatabase) AddBallotIDs(ballotIds []models.UsedBallotID) error
- func (db ElectionDatabase) AddNewCandidate(candidate *models.Candidate) error
- func (db ElectionDatabase) AddNewPost(post *models.Post) error
- func (db ElectionDatabase) AddNewVoter(voter *models.Voter) error
- func (db ElectionDatabase) ClearResults() error
- func (db ElectionDatabase) ClearSingleVoteResults() error
- func (db ElectionDatabase) DeleteAllVotes() error
- func (db ElectionDatabase) DeletePost(postId string) error
- func (db ElectionDatabase) EliminateCandidate(postId, roll string) error
- func (db ElectionDatabase) FindAllResults() ([]models.Result, error)
- func (db ElectionDatabase) FindAllSingleVoteResults() ([]models.SingleVoteResult, error)
- func (db ElectionDatabase) FindStudentSkeleton(roll string) (models.StudentSkeleton, error)
- func (db ElectionDatabase) FindVotedVoters() ([]models.Voter, error)
- func (db ElectionDatabase) FindVoter(roll string) (models.Voter, error)
- func (db ElectionDatabase) GetAllCandidates() ([]models.Candidate, error)
- func (db ElectionDatabase) GetCEO() (models.CEO, error)
- func (db ElectionDatabase) GetCandidate(username string) (models.Candidate, error)
- func (db ElectionDatabase) GetPosts() ([]models.Post, error)
- func (db ElectionDatabase) GetPostsForCEO() ([]models.Post, error)
- func (db ElectionDatabase) GetVotes() ([]models.Vote, error)
- func (db ElectionDatabase) InsertCEO(ceo *models.CEO) error
- func (db ElectionDatabase) InsertParsedVote(parsedVote *models.ParsedVote) error
- func (db ElectionDatabase) InsertResult(result *models.Result) error
- func (db ElectionDatabase) InsertSingleVoteResult(result *models.SingleVoteResult) error
- func (db ElectionDatabase) InsertVote(vote *models.Vote) error
- func (db ElectionDatabase) MarkAllVotersUnvoted() error
- func (db ElectionDatabase) MarkPostResolved(postId string) error
- func (db ElectionDatabase) ResetDatabase() error
- func (db ElectionDatabase) UpdateCEO(newCEO *models.CEO) error
- func (db ElectionDatabase) UpdateCandidate(username string, newCandidate *models.Candidate) error
- func (db ElectionDatabase) UpdateVoter(roll string, newVoter *models.Voter) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToInterfaceArray ¶
func ToInterfaceArray(s interface{}) []interface{}
Types ¶
type ElectionDatabase ¶
type ElectionDatabase struct { Session *mongo.Client VotersCollection *mongo.Collection CandidatesCollection *mongo.Collection CeoCollection *mongo.Collection PostsCollection *mongo.Collection BallotIdsCollection *mongo.Collection SingleVoteResultsCollection *mongo.Collection ResultsCollection *mongo.Collection StudentsCollection *mongo.Collection VotesCollection *mongo.Collection }
Struct that is used to store the session of the database connection.
func ConnectToDatabase ¶
func ConnectToDatabase() (ElectionDatabase, error)
Function to establish database connection.
func (ElectionDatabase) AddBallotIDs ¶
func (db ElectionDatabase) AddBallotIDs(ballotIds []models.UsedBallotID) error
func (ElectionDatabase) AddNewCandidate ¶
func (db ElectionDatabase) AddNewCandidate(candidate *models.Candidate) error
Function to insert a new candidate in the database.
func (ElectionDatabase) AddNewPost ¶
func (db ElectionDatabase) AddNewPost(post *models.Post) error
Function to insert a new post into the database.
func (ElectionDatabase) AddNewVoter ¶
func (db ElectionDatabase) AddNewVoter(voter *models.Voter) error
Function to insert a new voter into the database.
func (ElectionDatabase) ClearResults ¶
func (db ElectionDatabase) ClearResults() error
func (ElectionDatabase) ClearSingleVoteResults ¶
func (db ElectionDatabase) ClearSingleVoteResults() error
func (ElectionDatabase) DeleteAllVotes ¶
func (db ElectionDatabase) DeleteAllVotes() error
func (ElectionDatabase) DeletePost ¶
func (db ElectionDatabase) DeletePost(postId string) error
func (ElectionDatabase) EliminateCandidate ¶
func (db ElectionDatabase) EliminateCandidate(postId, roll string) error
Function to delete a candidate from the database.
func (ElectionDatabase) FindAllResults ¶
func (db ElectionDatabase) FindAllResults() ([]models.Result, error)
func (ElectionDatabase) FindAllSingleVoteResults ¶
func (db ElectionDatabase) FindAllSingleVoteResults() ([]models.SingleVoteResult, error)
func (ElectionDatabase) FindStudentSkeleton ¶
func (db ElectionDatabase) FindStudentSkeleton(roll string) (models.StudentSkeleton, error)
Function to find the basic details of a student from its roll number.
func (ElectionDatabase) FindVotedVoters ¶
func (db ElectionDatabase) FindVotedVoters() ([]models.Voter, error)
Function to find voters who have voted.
func (ElectionDatabase) FindVoter ¶
func (db ElectionDatabase) FindVoter(roll string) (models.Voter, error)
Function to find a voter in the database.
func (ElectionDatabase) GetAllCandidates ¶
func (db ElectionDatabase) GetAllCandidates() ([]models.Candidate, error)
Function to find all candidates in the database.
func (ElectionDatabase) GetCEO ¶
func (db ElectionDatabase) GetCEO() (models.CEO, error)
Function to get the details of the CEO from the database.
func (ElectionDatabase) GetCandidate ¶
func (db ElectionDatabase) GetCandidate(username string) (models.Candidate, error)
Function to find the candidate with that username in the database.
func (ElectionDatabase) GetPosts ¶
func (db ElectionDatabase) GetPosts() ([]models.Post, error)
Function to get all posts from the database.
func (ElectionDatabase) GetPostsForCEO ¶
func (db ElectionDatabase) GetPostsForCEO() ([]models.Post, error)
func (ElectionDatabase) GetVotes ¶
func (db ElectionDatabase) GetVotes() ([]models.Vote, error)
Function to get all the votes from the database.
func (ElectionDatabase) InsertCEO ¶
func (db ElectionDatabase) InsertCEO(ceo *models.CEO) error
Function to insert a new CEO into the database.
func (ElectionDatabase) InsertParsedVote ¶
func (db ElectionDatabase) InsertParsedVote(parsedVote *models.ParsedVote) error
Function to insert a new parsed vote into the database. TODO
func (ElectionDatabase) InsertResult ¶
func (db ElectionDatabase) InsertResult(result *models.Result) error
func (ElectionDatabase) InsertSingleVoteResult ¶
func (db ElectionDatabase) InsertSingleVoteResult(result *models.SingleVoteResult) error
Function to insert a new result into the database.
func (ElectionDatabase) InsertVote ¶
func (db ElectionDatabase) InsertVote(vote *models.Vote) error
Function to insert a new vote into the database.
func (ElectionDatabase) MarkAllVotersUnvoted ¶
func (db ElectionDatabase) MarkAllVotersUnvoted() error
func (ElectionDatabase) MarkPostResolved ¶
func (db ElectionDatabase) MarkPostResolved(postId string) error
func (ElectionDatabase) ResetDatabase ¶
func (db ElectionDatabase) ResetDatabase() error
Function to delete all entries from the database.
func (ElectionDatabase) UpdateCEO ¶
func (db ElectionDatabase) UpdateCEO(newCEO *models.CEO) error
Function ot update the details of the CEO.
func (ElectionDatabase) UpdateCandidate ¶
func (db ElectionDatabase) UpdateCandidate(username string, newCandidate *models.Candidate) error
Function to update the details of a candidate.
func (ElectionDatabase) UpdateVoter ¶
func (db ElectionDatabase) UpdateVoter(roll string, newVoter *models.Voter) error
Function to update the details of a voter.