Guest User

Untitled

a guest
Feb 9th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. _id : 5c5b450918cb2b121648ff7a
  2. name : "dannondarko"
  3. email : "dangilmail@gmail.com"
  4. password : "$2a$10$3z5m1e9Pcfid72Q2GchCjeTD55/SsIxmtWr3I1ZiA.DX/KlpfTbdK"
  5. date : 2019-02-06 20:35:21.973
  6. __v : 0
  7. posts : Array
  8. 0 : Object
  9. note : "test for the user dannondarko"
  10. date : "02/08/2019"
  11.  
  12. app.get('/:username', (req, res) => {
  13. username = req.params.username.toLowerCase();
  14. const collection = req.app.locals.collection;
  15.  
  16. collection.find({ name: username }).toArray(function (err, results) {
  17. if (err) {
  18. res.status(500).send("Error communicating with the DB.");
  19. } else if (results.length > 0) {
  20. console.log("Here are the results: " + results);
  21. console.log({people: results});
  22. res.status(200).render('profile', {posts: results, name: username});
  23. } else {
  24. next();
  25. }
  26. });
  27. });
  28.  
  29. <h1 class="mt-4"><%= name %></h1>
  30. <div class="container">
  31. <br>
  32. <% for(var i=0; i < posts.length; i++) { %>
  33. <div class="container">
  34. <label><%= posts[i].note %></label>
  35. <div class="container">
  36. <label><%= posts[i].date %></label>
  37. </div>
  38. </div>
  39. <% } %>
  40. </div>
Add Comment
Please, Sign In to add comment