Skip to content
Snippets Groups Projects
Commit fc38e946 authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

add update mongoose validation

parent 1ae97513
No related branches found
No related tags found
2 merge requests!29version 0.9,!28API and Schema rework
Pipeline #5655 passed
......@@ -21,7 +21,11 @@ const updateTerm = () => async (
if (value) newFields[field] = value;
});
await Term.updateOne({ _id: req.params.termId }, { $set: newFields })
await Term.updateOne(
{ _id: req.params.termId },
{ $set: newFields },
{ upsert: true, runValidators: true }
)
.lean()
.exec();
......
......@@ -22,7 +22,11 @@ const updateUser = () => async (
if (value) newFields[field] = value;
});
await Profile.updateOne({ _id: req.params.userId }, { $set: newFields })
await Profile.updateOne(
{ _id: req.params.userId },
{ $set: newFields },
{ upsert: true, runValidators: true }
)
.lean()
.exec();
......
......@@ -19,7 +19,11 @@ const updateWarning = () => async (
if (value) newFields[field] = value;
});
await Warning.updateOne({ _id: req.params.warningId }, { $set: newFields })
await Warning.updateOne(
{ _id: req.params.warningId },
{ $set: newFields },
{ upsert: true, runValidators: true }
)
.lean()
.exec();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment