diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 521e726..530f193 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -280,7 +280,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "aid": "123456", + "uid": "123456", "password": "myawesomepassword123" } ``` @@ -307,7 +307,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "tid": "123456", + "uid": "123456", "password": "myawesomepassword123" } ``` @@ -334,7 +334,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "sid": "123456", + "uid": "123456", "password": "myawesomepassword123" } ``` @@ -432,7 +432,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "sid": "123456", + "uid": "123456", "firstname": "Lisa", "middlename": "Marie", // (OPTIONAL) "lastname": "Simpson" @@ -462,7 +462,7 @@ There are several account that can be registered into the system. As you may gue * JSON": ```jsonc { - "sid": "123456", + "uid": "123456", "gradelevel": 11 } ``` @@ -490,7 +490,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "sid": "123456", + "uid": "123456", "homeroom": "A123" } ``` @@ -518,7 +518,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "sid": "123456", + "uid": "123456", "lockernumber": "B123" } ``` @@ -546,7 +546,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "sid": "123456", + "uid": "123456", "yog": 2020 } ``` @@ -606,7 +606,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "sid": "123456", // (Only required if signed in as admin) + "uid": "123456", // (Only required if signed in as admin) "email": "BartSimpsonsCoolEmail@example.com" } ``` @@ -634,7 +634,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "sid": "123456", + "uid": "123456", "address": "742 Evergreen Terrace", "city": "Springfield", "province": "...", @@ -691,7 +691,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "tid": "123456", + "uid": "123456", "firstname": "Marjorie", "middlename": "Jacqueline", // (Optional) "lastname": "Simpson" @@ -721,7 +721,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "tid": "123456", + "uid": "123456", "homeroom": "A123" } ``` @@ -781,7 +781,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "tid": "123456", // (Only required if igned in as admin) + "uid": "123456", // (Only required if igned in as admin) "email": "MargeSimpson@example.com" } ``` @@ -809,7 +809,7 @@ There are several account that can be registered into the system. As you may gue * JSON: ```jsonc { - "tid": "123456", + "uid": "123456", "address": "742 Evergreen Terrace", "city": "Springfield", "province": "...", @@ -954,7 +954,7 @@ In the case of an emergency for a specified student, a contact is required to be * JSON: ```jsonc { - "sid": "123456", + "uid": "123456", "firstname": "Marge", "middlename": "Jacqueline", // (optional) "lastname": "Simpson", @@ -1197,7 +1197,7 @@ Students and staff are bound to leave the school at some time, so there is a way * JSON: ```jsonc { - "aid": "123456" + "uid": "123456" } ``` @@ -1224,7 +1224,7 @@ Students and staff are bound to leave the school at some time, so there is a way * JSON: ```jsonc { - "tid": "123456" + "uid": "123456" } ``` @@ -1251,7 +1251,7 @@ Students and staff are bound to leave the school at some time, so there is a way * JSON: ```jsonc { - "sid": "123456" + "uid": "123456" } ``` @@ -1313,7 +1313,7 @@ Administrators play a very important role in managing a school, they do much wor * JSON: ```jsonc { - "sid": "123456" + "uid": "123456" } ``` @@ -1341,7 +1341,7 @@ Administrators play a very important role in managing a school, they do much wor * JSON: ```jsonc { - "tid": "123456" + "uid": "123456" } ``` diff --git a/controllers/authController.go b/controllers/authController.go index 8b1b003..e2b4ac6 100644 --- a/controllers/authController.go +++ b/controllers/authController.go @@ -624,7 +624,7 @@ func StudentLogin(c *fiber.Ctx) error { } // Check required fields are included - if data["sid"] == "" || data["password"] == "" { + if data["uid"] == "" || data["password"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -633,7 +633,7 @@ func StudentLogin(c *fiber.Ctx) error { } var student models.Student - err := StudentCollection.FindOne(ctx, bson.M{"school.sid": data["sid"]}).Decode(&student) + err := StudentCollection.FindOne(ctx, bson.M{"school.sid": data["uid"]}).Decode(&student) if err != nil { cancel() @@ -666,7 +666,7 @@ func StudentLogin(c *fiber.Ctx) error { _, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -715,7 +715,7 @@ func StudentLogin(c *fiber.Ctx) error { _, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) cancel() @@ -742,7 +742,7 @@ func StudentLogin(c *fiber.Ctx) error { _, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -796,7 +796,7 @@ func TeacherLogin(c *fiber.Ctx) error { } // Check required fields are included - if data["tid"] == "" || data["password"] == "" { + if data["uid"] == "" || data["password"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -805,7 +805,7 @@ func TeacherLogin(c *fiber.Ctx) error { } var teacher models.Teacher - err := TeacherCollection.FindOne(ctx, bson.M{"school.tid": data["tid"]}).Decode(&teacher) + err := TeacherCollection.FindOne(ctx, bson.M{"school.tid": data["uid"]}).Decode(&teacher) defer cancel() if err != nil { @@ -866,7 +866,7 @@ func AdminLogin(c *fiber.Ctx) error { } // Check required fields are included - if data["aid"] == "" || data["password"] == "" { + if data["uid"] == "" || data["password"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -875,7 +875,7 @@ func AdminLogin(c *fiber.Ctx) error { } var admin models.Admin - err := AdminCollection.FindOne(ctx, bson.M{"aid": data["aid"]}).Decode(&admin) + err := AdminCollection.FindOne(ctx, bson.M{"aid": data["uid"]}).Decode(&admin) defer cancel() if err != nil { @@ -936,13 +936,13 @@ func Student(c *fiber.Ctx) error { } // Check required fields are included - if data["sid"] == "" { + if data["uid"] == "" { return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, "message": "missing required fields", }) } - sid = data["sid"] + sid = data["uid"] } else { cookie := c.Cookies("jwt") @@ -1118,7 +1118,7 @@ func CreateContact(c *fiber.Ctx) error { } // Check required fields are included - if data["sid"] == nil || data["firstname"] == nil || data["lastname"] == nil || data["homephone"] == nil || data["email"] == nil || data["priority"] == nil || data["relation"] == nil { + if data["uid"] == nil || data["firstname"] == nil || data["lastname"] == nil || data["homephone"] == nil || data["email"] == nil || data["priority"] == nil || data["relation"] == nil { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -1161,7 +1161,7 @@ func CreateContact(c *fiber.Ctx) error { } _, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"sid": data["sid"]}, + bson.M{"sid": data["uid"]}, update, ) if updateErr != nil { @@ -1251,7 +1251,7 @@ func RemoveStudent(c *fiber.Ctx) error { } // Check student id is included - if data["sid"] == "" { + if data["uid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -1259,7 +1259,7 @@ func RemoveStudent(c *fiber.Ctx) error { }) } - _, deleteErr := IdCollection.DeleteOne(ctx, bson.M{"cid": data["sid"]}) + _, deleteErr := IdCollection.DeleteOne(ctx, bson.M{"cid": data["uid"]}) if deleteErr != nil { cancel() return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ @@ -1269,7 +1269,7 @@ func RemoveStudent(c *fiber.Ctx) error { }) } - _, deleteErr = StudentCollection.DeleteOne(ctx, bson.M{"school.sid": data["sid"]}) + _, deleteErr = StudentCollection.DeleteOne(ctx, bson.M{"school.sid": data["uid"]}) if deleteErr != nil { cancel() return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ @@ -1309,7 +1309,7 @@ func RemoveTeacher(c *fiber.Ctx) error { } // Check student id is included - if data["tid"] == "" { + if data["uid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -1317,7 +1317,7 @@ func RemoveTeacher(c *fiber.Ctx) error { }) } - _, deleteErr := IdCollection.DeleteOne(ctx, bson.M{"cid": data["tid"]}) + _, deleteErr := IdCollection.DeleteOne(ctx, bson.M{"cid": data["uid"]}) if deleteErr != nil { cancel() return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ @@ -1327,7 +1327,7 @@ func RemoveTeacher(c *fiber.Ctx) error { }) } - _, deleteErr = TeacherCollection.DeleteOne(ctx, bson.M{"school.tid": data["tid"]}) + _, deleteErr = TeacherCollection.DeleteOne(ctx, bson.M{"school.tid": data["uid"]}) if deleteErr != nil { cancel() return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ @@ -1367,7 +1367,7 @@ func RemoveAdmin(c *fiber.Ctx) error { } // Check student id is included - if data["aid"] == "" { + if data["uid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -1375,7 +1375,7 @@ func RemoveAdmin(c *fiber.Ctx) error { }) } - _, deleteErr := IdCollection.DeleteOne(ctx, bson.M{"cid": data["aid"]}) + _, deleteErr := IdCollection.DeleteOne(ctx, bson.M{"cid": data["uid"]}) if deleteErr != nil { cancel() return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ @@ -1385,7 +1385,7 @@ func RemoveAdmin(c *fiber.Ctx) error { }) } - _, deleteErr = AdminCollection.DeleteOne(ctx, bson.M{"aid": data["aid"]}) + _, deleteErr = AdminCollection.DeleteOne(ctx, bson.M{"aid": data["uid"]}) if deleteErr != nil { cancel() return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{ diff --git a/controllers/update/adminController.go b/controllers/update/adminController.go index b82ff90..6130970 100644 --- a/controllers/update/adminController.go +++ b/controllers/update/adminController.go @@ -358,7 +358,7 @@ func RemoveStudentsDisabled(c *fiber.Ctx) error { } // Check required fields are included - if data["sid"] == "" { + if data["uid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -378,7 +378,7 @@ func RemoveStudentsDisabled(c *fiber.Ctx) error { result, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -421,7 +421,7 @@ func RemoveTeachersDisabled(c *fiber.Ctx) error { } // Check required fields are included - if data["tid"] == "" { + if data["uid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -440,7 +440,7 @@ func RemoveTeachersDisabled(c *fiber.Ctx) error { result, updateErr := TeacherCollection.UpdateOne( ctx, - bson.M{"school.tid": data["tid"]}, + bson.M{"school.tid": data["uid"]}, update, ) if updateErr != nil { diff --git a/controllers/update/studentController.go b/controllers/update/studentController.go index fddde15..15ed24f 100644 --- a/controllers/update/studentController.go +++ b/controllers/update/studentController.go @@ -45,7 +45,7 @@ func UpdateStudentName(c *fiber.Ctx) error { // Check id and names are included // Middle name is optional - if data["sid"] == "" || data["firstname"] == "" || data["lastname"] == "" { + if data["uid"] == "" || data["firstname"] == "" || data["lastname"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -81,7 +81,7 @@ func UpdateStudentName(c *fiber.Ctx) error { result, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -124,7 +124,7 @@ func UpdateStudentGradeLevel(c *fiber.Ctx) error { } // Check required fields are included - if data["sid"] == nil || data["gradelevel"] == nil { + if data["uid"] == nil || data["gradelevel"] == nil { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -142,7 +142,7 @@ func UpdateStudentGradeLevel(c *fiber.Ctx) error { _, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"].(string)}, + bson.M{"school.sid": data["uid"].(string)}, update, ) if updateErr != nil { @@ -195,7 +195,7 @@ func UpdateStudentHomeroom(c *fiber.Ctx) error { } // Check required fields are included - if data["sid"] == "" || data["homeroom"] == "" { + if data["uid"] == "" || data["homeroom"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -213,7 +213,7 @@ func UpdateStudentHomeroom(c *fiber.Ctx) error { _, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -363,7 +363,7 @@ func ResetStudentPassword(c *fiber.Ctx) error { } // Check required fields are included (email must be personal email) - if data["sid"] == "" || data["email"] == "" { + if data["uid"] == "" || data["email"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -372,7 +372,7 @@ func ResetStudentPassword(c *fiber.Ctx) error { } var student models.Student - findErr := StudentCollection.FindOne(context.TODO(), bson.M{"school.sid": data["sid"]}).Decode(&student) + findErr := StudentCollection.FindOne(context.TODO(), bson.M{"school.sid": data["uid"]}).Decode(&student) if findErr != nil { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ @@ -401,7 +401,7 @@ func ResetStudentPassword(c *fiber.Ctx) error { result, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -456,7 +456,7 @@ func UpdateStudentLocker(c *fiber.Ctx) error { } // Check id and locker are included - if data["sid"] == "" || data["lockernumber"] == "" { + if data["uid"] == "" || data["lockernumber"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -485,7 +485,7 @@ func UpdateStudentLocker(c *fiber.Ctx) error { _, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -527,7 +527,7 @@ func UpdateStudentAddress(c *fiber.Ctx) error { } // Check required fields are included - if data["sid"] == "" || data["address"] == "" || data["city"] == "" || data["province"] == "" || data["postal"] == "" { + if data["uid"] == "" || data["address"] == "" || data["city"] == "" || data["province"] == "" || data["postal"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -548,7 +548,7 @@ func UpdateStudentAddress(c *fiber.Ctx) error { _, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"sid": data["sid"]}, + bson.M{"sid": data["uid"]}, update, ) if updateErr != nil { @@ -591,7 +591,7 @@ func UpdateStudentYOG(c *fiber.Ctx) error { } // Check required fields are included - if data["sid"] == "" || data["yog"] == nil { + if data["uid"] == "" || data["yog"] == nil { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -600,7 +600,7 @@ func UpdateStudentYOG(c *fiber.Ctx) error { } var student models.Student - findErr := StudentCollection.FindOne(context.TODO(), bson.M{"school.sid": data["sid"].(string)}).Decode(&student) + findErr := StudentCollection.FindOne(context.TODO(), bson.M{"school.sid": data["uid"].(string)}).Decode(&student) if findErr != nil { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ @@ -619,7 +619,7 @@ func UpdateStudentYOG(c *fiber.Ctx) error { result, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"].(string)}, + bson.M{"school.sid": data["uid"].(string)}, update, ) if updateErr != nil { @@ -662,7 +662,7 @@ func RemoveStudentContact(c *fiber.Ctx) error { } // Check id and contact id are included - if data["sid"] == "" || data["contactid"] == "" { + if data["uid"] == "" || data["contactid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -693,7 +693,7 @@ func RemoveStudentContact(c *fiber.Ctx) error { result, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -736,7 +736,7 @@ func AddStudentContact(c *fiber.Ctx) error { } // Check id and contact id are included - if data["sid"] == "" || data["contactid"] == "" { + if data["uid"] == "" || data["contactid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -767,7 +767,7 @@ func AddStudentContact(c *fiber.Ctx) error { result, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.sid": data["sid"]}, + bson.M{"school.sid": data["uid"]}, update, ) if updateErr != nil { @@ -929,14 +929,14 @@ func UpdateStudentEmail(c *fiber.Ctx) error { }) } - if verifiedAdmin && data["sid"] == "" { + if verifiedAdmin && data["uid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, "message": "missing required fields", }) } else if verifiedAdmin { - sid = data["sid"] + sid = data["uid"] } // Check required fields are included diff --git a/controllers/update/teacherController.go b/controllers/update/teacherController.go index 36280e9..99a4a16 100644 --- a/controllers/update/teacherController.go +++ b/controllers/update/teacherController.go @@ -50,7 +50,7 @@ func UpdateTeacherHomeroom(c *fiber.Ctx) error { } // Check required fields are included - if data["tid"] == "" || data["homeroom"] == "" { + if data["uid"] == "" || data["homeroom"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -68,7 +68,7 @@ func UpdateTeacherHomeroom(c *fiber.Ctx) error { _, updateErr := TeacherCollection.UpdateOne( ctx, - bson.M{"school.tid": data["tid"]}, + bson.M{"school.tid": data["uid"]}, update, ) if updateErr != nil { @@ -216,7 +216,7 @@ func ResetTeacherPassword(c *fiber.Ctx) error { } // Check required fields are included (email must be personal email) - if data["tid"] == "" || data["email"] == "" { + if data["uid"] == "" || data["email"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -225,7 +225,7 @@ func ResetTeacherPassword(c *fiber.Ctx) error { } var teacher models.Teacher - findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"school.tid": data["tid"]}).Decode(&teacher) + findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"school.tid": data["uid"]}).Decode(&teacher) if findErr != nil { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ @@ -254,7 +254,7 @@ func ResetTeacherPassword(c *fiber.Ctx) error { result, updateErr := StudentCollection.UpdateOne( ctx, - bson.M{"school.tid": data["tid"]}, + bson.M{"school.tid": data["uid"]}, update, ) if updateErr != nil { @@ -309,7 +309,7 @@ func UpdateTeacherAddress(c *fiber.Ctx) error { } // Check required fields are included - if data["tid"] == "" || data["address"] == "" || data["city"] == "" || data["province"] == "" || data["postal"] == "" { + if data["uid"] == "" || data["address"] == "" || data["city"] == "" || data["province"] == "" || data["postal"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -330,7 +330,7 @@ func UpdateTeacherAddress(c *fiber.Ctx) error { _, updateErr := TeacherCollection.UpdateOne( ctx, - bson.M{"school.tid": data["tid"]}, + bson.M{"school.tid": data["uid"]}, update, ) if updateErr != nil { @@ -492,14 +492,14 @@ func UpdateTeacherEmail(c *fiber.Ctx) error { }) } - if verifiedAdmin && data["tid"] == "" { + if verifiedAdmin && data["uid"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, "message": "missing required fields", }) } else if verifiedAdmin { - tid = data["tid"] + tid = data["uid"] } // Check required fields are included @@ -563,7 +563,7 @@ func UpdateTeacherName(c *fiber.Ctx) error { } // Check id and names are included - if data["tid"] == "" || data["firstname"] == "" || data["lastname"] == "" { + if data["uid"] == "" || data["firstname"] == "" || data["lastname"] == "" { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "success": false, @@ -573,7 +573,7 @@ func UpdateTeacherName(c *fiber.Ctx) error { // Get teacher var teacher models.Teacher - findErr := TeacherCollection.FindOne(ctx, bson.M{"school.tid": data["tid"]}).Decode(&teacher) + findErr := TeacherCollection.FindOne(ctx, bson.M{"school.tid": data["uid"]}).Decode(&teacher) if findErr != nil { cancel() return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ @@ -601,7 +601,7 @@ func UpdateTeacherName(c *fiber.Ctx) error { _, updateErr := TeacherCollection.UpdateOne( ctx, - bson.M{"school.tid": data["tid"]}, + bson.M{"school.tid": data["uid"]}, update, ) if updateErr != nil {