Skip to content
Snippets Groups Projects
Commit ffeeb9aa authored by elit04's avatar elit04
Browse files

working update boat controller

parent f1ebf42e
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,6 @@ const createBoat = async (req: Request, res: Response) => {
//if there is a sport, which isn't in the database, we return an array with the names of the missing sports
if (check === false) {
console.log("list", listIfNotFound);
return res.status(404).json({
success: false,
error: "The SportIDs: " + listIfNotFound + " cannotBeFound",
......@@ -265,7 +264,6 @@ const updateBoatById = async (req: Request, res: Response) => {
//if the updated-to-be sportid(sportids) doesn't exist
if (check === false) {
console.log("list", listIfNotFound);
return res
.status(404)
.json({ success: false, error: listIfNotFound + " sportIdNotFound" });
......@@ -295,7 +293,8 @@ const updateBoatById = async (req: Request, res: Response) => {
});
//we need this special case res, because sports is not an attribute assigned to Boat table, and if only sports provided as request body error happens
if (updatedBoat === undefined) {
// check if in the requested body only values for sports were provided
if (Object.keys(input).length === 1 && !(input.sports === undefined)) {
//return after updating
return res.status(200).json({
success: true,
......@@ -314,7 +313,6 @@ const updateBoatById = async (req: Request, res: Response) => {
//case where in request body attributes from Boat provided + sports which is an attribute in Sport table and connection between Boat and Sport is saved in BoatHasSport table
const boatDataAfterUpdate = updatedBoat[1][0];
console.log("boatDataAfterUpdate ", boatDataAfterUpdate);
return res.status(200).json({
success: true,
result: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment