I have this JSON which represents an apartment listing:
{
"_id": {
"$oid": "5673d1dcf93fe452d80c2c2c"
},
"street": "myStreet",
"buildingNumber": 1,
"apartmentNumber": 1,
"UsersAndQuestions": [
{
"userID": "5673afe4cb62303816bd3d5c",
"questionID": [
"5669d90a058ceddc158e97e2",
"4668d80b158ceggc158e97f2"
]
}
]
}
I want to get the questionID
array of a certain userID
.
I am using this http.get
to try and get it:
app.get('/api/listing/getQuestionsOfUserInListing/:userid/:listingid', function (req, res) {
var user = req.params.userid;
var listing = req.params.listingid;
Listing.find({
$and: [
{_id: listing},
{'UsersAndQuestions.userID': user}
]
}
, function (err, result) {
res.json(result);
});
});
But I'm just getting back the whole JSON (exactly the one I posted in the beginning of the question).
How can I get just the
"questionID": ["5669d90a058ceddc158e97e2", "4668d80b158ceggc158e97f2"]
?
Thanks!