mirror of
https://github.com/arnaucube/commonroutesServer.git
synced 2026-02-28 05:26:42 +01:00
delete travel and join travel implemented
This commit is contained in:
@@ -4,6 +4,8 @@ var travelModel = mongoose.model('travelModel');
|
||||
|
||||
var userModel = mongoose.model('userModel');
|
||||
|
||||
var joinModel = mongoose.model('joinModel');
|
||||
|
||||
//GET
|
||||
exports.findAllTravels = function(req, res) {
|
||||
|
||||
@@ -100,3 +102,38 @@ exports.deleteTravel = function(req, res) {
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/* join */
|
||||
exports.addJoin = function(req, res) {
|
||||
var join = new joinModel({
|
||||
travelId: req.body.travelId,
|
||||
joinedUserId: req.body.joinedUserId,
|
||||
joinedUsername: req.body.joinedUsername,
|
||||
acceptedUserId: req.body.acceptedUserId,
|
||||
comment: req.body.comment
|
||||
});
|
||||
|
||||
join.save(function(err, join) {
|
||||
if(err) return res.send(500, err.message);
|
||||
res.status(200).jsonp(join);
|
||||
});
|
||||
};
|
||||
|
||||
exports.getJoinsByTravelId = function(req, res) {
|
||||
joinModel.find({
|
||||
travelId: req.params.travelId
|
||||
}, function(err, joins) {
|
||||
|
||||
if (err) throw err;
|
||||
|
||||
if (!joins) {
|
||||
res.json({ success: false, message: 'no joins for travelId' });
|
||||
} else if (joins) {
|
||||
// return the information including token as JSON
|
||||
res.jsonp(joins);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
@@ -34,8 +34,9 @@ exports.findById = function(req, res) {
|
||||
|
||||
console.log('GET /users/' + req.params.id);
|
||||
//password deletion
|
||||
|
||||
if(user!=null){
|
||||
user.password="";
|
||||
}
|
||||
res.status(200).jsonp(user);
|
||||
});
|
||||
};
|
||||
@@ -144,7 +145,8 @@ console.log(user);
|
||||
success: true,
|
||||
message: 'Enjoy your token!',
|
||||
token: token,
|
||||
avatar: user.avatar
|
||||
avatar: user.avatar,
|
||||
userid: user._id
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user