|
|
@@ -120,23 +120,23 @@ shelfRoutes.put('/update/', jwtAuthentication, async (request, response) => { |
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < updatedAddedWords.length; i += 1) { |
|
|
|
if (!updatedAddedWords[i].word || !updatedAddedWords[i].isArchived || |
|
|
|
!updatedAddedWords[i].isFavourite || !updatedAddedWords[i].nextRevisionDateTime || |
|
|
|
!updatedAddedWords[i].notes || !updatedAddedWords[i].revisionHistory || !updatedAddedWords[i].spaceBetweenRecall) { |
|
|
|
if (!updatedAddedWords[i].word || updatedAddedWords[i].isArchived === undefined || |
|
|
|
updatedAddedWords[i].isFavourite === undefined || !updatedAddedWords[i].nextRevisionDateTime || |
|
|
|
updatedAddedWords[i].notes === undefined || updatedAddedWords[i].revisionHistory === undefined || |
|
|
|
!updatedAddedWords[i].spaceBetweenRecall) { |
|
|
|
response.status(400); |
|
|
|
response.send("Missing key in " + JSON.stringify(updatedAddedWords[i])); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const wordId = updatedAddedWords[i].word; |
|
|
|
|
|
|
|
const matchedWord = await wordCollection.findOne({ |
|
|
|
_id: new ObjectId(wordId) |
|
|
|
}); |
|
|
|
|
|
|
|
if (!matchedWord) { |
|
|
|
response.status(400); |
|
|
|
response.send("Word with ID " + updatedAddedWords[i] + " is not present in the library" ); |
|
|
|
response.send("Word with ID " + updatedAddedWords[i].word + " is not present in the library" ); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|