Created
September 10, 2017 15:22
-
-
Save nazrdogan/52a6ae316c283373119c337c3acb55f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get("/allSurgun", isAuth, function(req, res) { | |
User.findOne({ _id: req.decoded }, function(err, user) { | |
if (err) throw err; | |
if (!user) | |
res.status(400).json({ | |
success: false, | |
data: "Kullanıcı bulunamadı!" | |
}); | |
//If have a user. | |
Surgun.find({ _id: { $in: user.surgun } }, function(err, surgunData) { | |
if (err) throw err; | |
if (surgunData.length <= 0) { | |
res.status(400).json({ | |
success: false, | |
data: "Veri bulunamadı!" | |
}); | |
} | |
var surgunObj = surgunData.map(function(data) { | |
var obj = { | |
_id: data._id, | |
name: data.surgunNumarasi | |
}; | |
return obj; | |
}); | |
res.json({ success: true, data: surgunObj }); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment