Skip to content

Commit

Permalink
storing marks & time
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishita2803 committed Feb 24, 2022
1 parent 9038fb7 commit f98dfd0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion login-register/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./node_modules
/node_modules
3 changes: 2 additions & 1 deletion login-register/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ userSchema = new Schema( {
username: String,
password: String,
passwordConf: String,

marks:Number,
time:String
}),
User = mongoose.model('User', userSchema);

Expand Down
36 changes: 34 additions & 2 deletions login-register/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ router.get('/', function (req, res, next) {
router.post('/', function(req, res, next) {
console.log(req.body);
var personInfo = req.body;


if(!personInfo.email || !personInfo.username || !personInfo.password || !personInfo.passwordConf){
res.send();
} else {
Expand Down Expand Up @@ -145,4 +143,38 @@ router.post('/forgetpass', function (req, res, next) {

});

router.put('/marks/:id',async(req,res)=>{
try {
const user = await User.findById(req.params.id)
user.marks = req.body.marks
const data = await user.save()
res.json(data)
} catch (error) {
res.send(error)
}
})

router.put('/time/:id',async(req,res)=>{
try {
const user = await User.findById(req.params.id)
user.time = req.body.time
const data = await user.save()
res.json(data)
} catch (error) {
res.send(error)
}
})

router.get("/view", async(req,res)=>{
try {
const data=await User.find()
res.send(data)
console.log(req.body);
} catch (err) {
res.status(500).send({
message: err.message || "Some error occurred while retrieving users."
});
}
})

module.exports = router;

0 comments on commit f98dfd0

Please sign in to comment.