Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. keystone.list('Blurt').model.aggregate([
  2. {
  3. $lookup:{
  4. from: "users",
  5. localField: "author.id",
  6. foreignField: "_id",
  7. as: "userImg"
  8. }
  9. }
  10. ,
  11. {
  12. $unwind: '$userImg'
  13. },
  14. {
  15. $match: { 'author.id': {$ne: req.user._id}}
  16. },
  17. {
  18. $sample: {'size': 3}
  19. },
  20. {
  21. $project: {
  22. _id: '$userImg._id',
  23. name: '$userImg.name',
  24. smImg: '$userImg.smImg',
  25. text: 1,
  26. vote: 1,
  27. blurtDate: 1,
  28. blurtImg: 1
  29. }
  30. }
  31. ]).sort({ blurtDate: -1 })
  32. .cursor().exec()
  33. .toArray(function(err, data) {
  34. console.log(data);
  35. res.json(data);
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement