Browse Source

user shortDefinition

master
arnaucode 7 years ago
parent
commit
339dd3e26c
3 changed files with 5 additions and 3 deletions
  1. +2
    -2
      controllers/eventController.js
  2. +2
    -1
      controllers/userController.js
  3. +1
    -0
      models/userModel.js

+ 2
- 2
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) {

+ 2
- 1
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) {

+ 1
- 0
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: {

Loading…
Cancel
Save