Documentation ¶
Index ¶
- func CreateExams(db *mongo.Client, exams []ExamCreate, databaseName, collectionName string) error
- func DeleteExams(db *mongo.Client, exams []Exam, databaseName, collectionName string) error
- func UpdateExams(db *mongo.Client, exams []Exam, databaseName, collectionName string) error
- type Exam
- type ExamCreate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateExams ¶
func CreateExams(db *mongo.Client, exams []ExamCreate, databaseName, collectionName string) error
CreateExams receive a list of exams Checks if that list is not null (can't insert null list) Insert each exams individually in database @param db pointer to database @param exams list of exams @param databaseName name of database @param collectionName name of collection @return error function error TODO : Insert all exams at the same time (if possible)
func DeleteExams ¶
DeleteExams recieve a list of exams (to be deleted) Checks if that list is not null (can't delete null list) Delete each exam individually @param db pointer to database (to be deleted) @param exams list of exams @param databaseName name of database @param collectionName name of collection @return error function error TODO : Delete all exams at the same time (if possible)
func UpdateExams ¶
UpdateExams receive list of exams (updated) Checks if exams old password matches with db to update that exams password or email @param db pointer to database (updated) @param exams list of exams @param databaseName name of database @param collectionName name of collection @return error function error
Types ¶
type Exam ¶
type Exam struct { ID primitive.ObjectID `bson:"_id,omitempty"` ClassID primitive.ObjectID `bson:"classid,omitempty"` Title string `json:"title"` }
Exam contains all exam data
func GetExams ¶
GetExams return list of all exams from Database Get all exams at the same time and store inside cursor Decode each exam inside exam class and append into exams array @param db pointer to database @param databaseName name of database @param collectionName name of collection @return []Exam list of all exams @return error function error
func GetExamsClass ¶
func GetExamsClass(db *mongo.Client, classID primitive.ObjectID, databaseName, collectionName string) ([]Exam, error)
GetExamsClass return list of all exams from a current class Get class id to filter in mongodb @param db pointer to database @param classID class ID @param databaseName name of database @param collectionName name of collection @return []Exam list of all exams that match with the given class id @return error function error
type ExamCreate ¶
type ExamCreate struct { ClassID primitive.ObjectID `bson:"classid,omitempty"` Title string `json:"title"` }
Exam contains all exam data excepted from ID