12
14
15
}
}
Figure 4: Result after insert successfully
Using model validation to check data input:
Ο No "name" data field when creating a new department, shown in Figure 5 - (0.25 marks)
Body
500 Internal Server Error
6 ms 355 B
Pretty
Raw Preview Visualize
JSON
1
{
234
"error": {
"status": 500,
"message": "department validation failed: name: Department name is required"
Body
5
}
6
}
Figure 5: No "name" data field
Ο When department name has existed, as shown in Figure 6-(0.25 marks)
Pretty
Raw Preview Visualize
JSON
1
{
2
"error": {
3
4
"status": 500,
5
}
6
}
Q
500 Internal Server Error
30 ms 413 B...
"message": "E11000 duplicate key error collection: SDN301_FALL24_B1.departments
index: name_1 dup key: { name: \"Customer Service\"}"
Zoom
+ 95%
Figure 6: Duplicate value of department name
Close