forked from HITK-TECH-Community/Community-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
πΏ Update admin (HITK-TECH-Community#800)
* Update Admin * update admin route with validation * trying * push-again * tested route * Update updateAdmin.js
- Loading branch information
1 parent
8778514
commit 4e1a9e7
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const Admin = require('../../models/Admin'); | ||
|
||
module.exports =async (req, res) => { | ||
|
||
try { | ||
const updatedAdmin = await Admin.findByIdAndUpdate( | ||
req.params.id, | ||
{ | ||
$set: req.body, | ||
}, | ||
{ new: true } | ||
); | ||
res.status(200).json(updatedAdmin); | ||
} catch (err) { | ||
res.status(500).json(err); | ||
} | ||
res.send('Done'); | ||
}; |