From 339dd3e26c1c946c3b5d305b176e4d4dcf717f65 Mon Sep 17 00:00:00 2001 From: arnaucode Date: Sun, 19 Feb 2017 21:58:22 +0100 Subject: [PATCH] user shortDefinition --- controllers/eventController.js | 4 ++-- controllers/userController.js | 3 ++- models/userModel.js | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/controllers/eventController.js b/controllers/eventController.js index cfd7cec..f88e9eb 100644 --- a/controllers/eventController.js +++ b/controllers/eventController.js @@ -12,7 +12,7 @@ var pageSize=config.pageSize; exports.getAllEvents = function(req, res) { eventModel.find({date: {$gte: new Date()}}) .lean() - .populate('user', 'username') + .populate('user', 'username img shortDescription') .sort('date') .limit(pageSize) .skip(pageSize * Number(req.query.page)) @@ -24,7 +24,7 @@ exports.getAllEvents = function(req, res) { exports.getEventById = function (req, res) { eventModel.findOne({_id: req.params.eventid}) .lean() - .populate('user', 'username img description') + .populate('user', 'username img shortDescription') .exec(function (err, event) { if (err) return res.send(500, err.message); if (!event) { diff --git a/controllers/userController.js b/controllers/userController.js index 03b0071..5cc39c1 100644 --- a/controllers/userController.js +++ b/controllers/userController.js @@ -14,6 +14,7 @@ exports.signup = function (req, res) { var user = new userModel({ username: req.body.username, password: crypto.createHash('sha256').update(req.body.password).digest('base64'), + shortDescription: req.body.shortDescription, description: req.body.description, email: req.body.email }); @@ -103,7 +104,7 @@ exports.getAllUsers = function(req, res) { exports.getUserById = function (req, res) { userModel.findOne({_id: req.params.userid}) .lean() - .populate('events', 'title description img date') + .populate('events', 'title shortDescription description img date') .exec(function (err, user) { if (err) return res.send(500, err.message); if (!user) { diff --git a/models/userModel.js b/models/userModel.js index 97a3b1d..4190e4b 100644 --- a/models/userModel.js +++ b/models/userModel.js @@ -19,6 +19,7 @@ var userSchema = new Schema({ lastLogin: {type: Date, select: false}, birthdate: {type: Date, select: false}, }], + shortDescription: { type: String }, description: { type: String }, img: { type: String, default: "https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" }, contact: {