Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fahrtenbuch
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWP WS21_22 - Fahrtenbuch
Team Einhorn
fahrtenbuch
Commits
ffeeb9aa
Commit
ffeeb9aa
authored
3 years ago
by
elit04
Browse files
Options
Downloads
Patches
Plain Diff
working update boat controller
parent
f1ebf42e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/src/controllers/boat.controllers.ts
+2
-4
2 additions, 4 deletions
server/src/controllers/boat.controllers.ts
with
2 additions
and
4 deletions
server/src/controllers/boat.controllers.ts
+
2
−
4
View file @
ffeeb9aa
...
...
@@ -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
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment