Since there seems nobody is able to find a solution for my problem, I would like to ask my question in a different way: What should be the correct way to loop through the games section of the following object:
[
{
"_id": "5710b0ddab8b724011705037",
"username": "test",
"name": "testuser",
"__v": 0,
"library": {
"games": [
{
"platform": [
"17",
"94"
],
"name": "Simcity",
"id": "37620"
},
{
"platform": [
"146",
"20"
],
"name": "destiny",
"id": "36067"
}
],
"platforms": [
{
"name": "Xbox360",
"id": "20"
},
{
"name": "PC",
"id": "94"
}
]
}
}
]
This object is fetched out through mongoose out of a MongoDB, all happens in the API section of my NodeJS application:
.get('/test', function(req, res){
User.findOne({"username": req.decoded.username}, function(err, user){
// trying to loop here
});
})
I have tried everything I find, but I cannot get it to work, so I wonder what ways you use to do this, without cluttering your vision with my (maybe wrong) ways and errors...