-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete.js
61 lines (52 loc) · 1.67 KB
/
delete.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const express = require('express');
const router = express.Router();
const Evntpersonal = require('./models/Evntpersonal')
router.post('/', function(req, res) {
var userx;
Evntpersonal.findOne({email: req.body.username},(err, response) => {
userx = response;
userx.events = userx.events.filter((x) => {
if(x._id == req.body._id) {
return false;
}
else {
return true;
}
})
Evntpersonal.findOneAndUpdate({email:req.body.username}, {$set: userx}).
then(() => {
res.send({err: false, flag:true})
})
.catch(err => {
res.send({err: err, flag:false});
})
}).catch (error => {
res.send({err: error, flag:false});
})
// console.log(userx);
// userx.events = userx.events.filter((x) => {
// if(x._id == req.body._id) {
// return false;
// }
// else {
// return true;
// }
// })
// console.log(userx);
// Evntpersonal.findOneAndUpdate({email:req.body.username}, {$set: userx}).
// then(() => {
// res.send({err: false, flag:true})
// })
// .catch(err => {
// res.send({err: err, flag:false});
// })
// Evntpersonal.findOneAndUpdate({email:req.body.username}, {$set: {first_name: userx.first_name,
// last_name: userx.last_name, email: userx.email,password: userx.password,admin: userx.admin,events: x}}).
// then(() => {
// res.send({err: false, flag:true})
// })
// .catch(err => {
// res.send({err: err, flag:false});
// })
})
module.exports = router