Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- keystone.list('Blurt').model.aggregate([
- {
- $lookup:{
- from: "users",
- localField: "author.id",
- foreignField: "_id",
- as: "userImg"
- }
- }
- ,
- {
- $unwind: '$userImg'
- },
- {
- $match: { 'author.id': {$ne: req.user._id}}
- },
- {
- $sample: {'size': 3}
- },
- {
- $project: {
- _id: '$userImg._id',
- name: '$userImg.name',
- smImg: '$userImg.smImg',
- text: 1,
- vote: 1,
- blurtDate: 1,
- blurtImg: 1
- }
- }
- ]).sort({ blurtDate: -1 })
- .cursor().exec()
- .toArray(function(err, data) {
- console.log(data);
- res.json(data);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement