I'm trying to return certain elements of an array in the document below.
{
"_id": 2,
"awardAmount": 6000,
"url": "www.url.com",
"numAwards": 3,
"award": "Faculty Seed Research Grant",
"Type": "faculty",
"Applicates": [
{
"School": "psu",
"Name": "tom",
"URL": "www.url.com",
"Time": "",
"Research": "",
"Budge": 7500,
"appId": 100,
"citizenship": "us",
"Major": "mat",
"preAwards": "None",
"Advisor": ""
},
{
"School": "ffff",
"Name": "KEVIN",
"URL": "www.url.com",
"Time": "5/5/5-6/6/6",
"Research": "topology",
"Budge": 9850,
"appId": 101,
"citizenship": "us",
"Major": "gym",
"preAwards": "None",
"Advisor": "Dr. cool",
"Evaluators": [
{
"abstractScore": 3,
"goalsObjectivesScore": 4,
"evalNum": 1
},
{
"abstractScore": 545646,
"goalsObjectivesScore": 46546,
"evalNum": 2
}
]
}
]
}
I want only the "Applicates" data if they have an "Evaluators" field. Here is what I was trying
db.coll.find({'Applicates.Evaluators':{'$exists': True }})
This gives me the whole document but I just want "Applicates" data that have the "Evaluators" field in it like this.
{
"_id": 2,
"awardAmount": 6000,
"url": "www.url.com",
"numAwards": 3,
"award": "Faculty Seed Research Grant",
"Type": "faculty",
"Applicates": [
{
"School": "ffff",
"Name": "KEVIN",
"URL": "www.url.com",
"Time": "5/5/5-6/6/6",
"Research": "topology",
"Budge": 9850,
"appId": 101,
"citizenship": "us",
"Major": "gym",
"preAwards": "None",
"Advisor": "Dr. cool",
"Evaluators": [
{
"abstractScore": 3,
"goalsObjectivesScore": 4,
"evalNum": 1
},
{
"abstractScore": 545646,
"goalsObjectivesScore": 46546,
"evalNum": 2
}
]
}
]
}