Guest User

Untitled

a guest
Dec 14th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. app.get('/delete:id', (req, res,next) => {
  2. var id = req.params.id;
  3. console.log(id);
  4. var myquery = { Empid:id};
  5. db.collection("emp").remove(myquery, function(err, obj) {
  6. if (err) throw err;
  7. res.redirect('/');
  8. console.log(obj.result.n + " document(s) deleted");
  9. db.close();
  10. });
  11. });
  12.  
  13. <table class="emp" border="1" id="emptable">
  14. <thead>
  15. <tr>
  16. <th>_id</th>
  17. <th>EmpId</th>
  18. <th>Name</th>
  19. <th>Mobile</th>
  20. <th>Email_id</th>
  21. <th>Designation</th>
  22. <th>Company</th>
  23. <th>Experience</th>
  24. <th>Work Details</th>
  25. <th>Address</th>
  26. <th>City</th>
  27. <th>State</th>
  28. <th>PinCode</th>
  29. <th>Action</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. <% for(var i=0; i < emp.length; i++) { %>
  34. <tr>
  35. <td><%= emp[i]._id %></td>
  36. <td><%= emp[i].Empid %></td>
  37. <td><%= emp[i].Name %></td>
  38.  
  39. <td><%= emp[i].Mobile %></td>
  40. <td><%= emp[i].Email_id %></td>
  41. <td><%= emp[i].Designation %></td>
  42.  
  43. <td><%= emp[i].Company %></td>
  44. <td><%= emp[i].Experience %></td>
  45. <td><%= emp[i].Work %></td>s
  46. <td><%= emp[i].Address%></td>
  47. <td><%= emp[i].City %></td>
  48. <td><%= emp[i].State %></td>
  49. <td><%= emp[i].Pincode %></td>
  50. <td><a href='/delete' action='/'><%id= emp[i].Empid %>Delete</a>
  51. </td>
Add Comment
Please, Sign In to add comment