|
@ -11,6 +11,8 @@ var pageSize=config.pageSize; |
|
|
|
|
|
|
|
|
exports.getAllEvents = function(req, res) { |
|
|
exports.getAllEvents = function(req, res) { |
|
|
eventModel.find({date: {$gte: new Date()}}) |
|
|
eventModel.find({date: {$gte: new Date()}}) |
|
|
|
|
|
.lean() |
|
|
|
|
|
.populate('user', 'username') |
|
|
.sort('date') |
|
|
.sort('date') |
|
|
.limit(pageSize) |
|
|
.limit(pageSize) |
|
|
.skip(pageSize * Number(req.query.page)) |
|
|
.skip(pageSize * Number(req.query.page)) |
|
@ -22,7 +24,7 @@ exports.getAllEvents = function(req, res) { |
|
|
exports.getEventById = function (req, res) { |
|
|
exports.getEventById = function (req, res) { |
|
|
eventModel.findOne({_id: req.params.eventid}) |
|
|
eventModel.findOne({_id: req.params.eventid}) |
|
|
.lean() |
|
|
.lean() |
|
|
.populate('user', 'username avatar telegram phone') |
|
|
|
|
|
|
|
|
.populate('user', 'username img description') |
|
|
.exec(function (err, event) { |
|
|
.exec(function (err, event) { |
|
|
if (err) return res.send(500, err.message); |
|
|
if (err) return res.send(500, err.message); |
|
|
if (!event) { |
|
|
if (!event) { |
|
|