C-Driver Access nested fields

Hello @Alexander_Laub,

I want to suggest a better way of structuring the data you had posted. Ideally, the data should be as follows. There is an array field skills with sub-documents (nested) as array elements. This will allow more than two skills (or as more skills might show up later):

skills: [
    { 
        id: 1,
        name: "DrillHole",
        status: "PENDING",
        parameter: "10"
    },
    { 
        id: 2,
        name: "DrillSlot",
        status: "PENDING",
        parameter: "11"
    }
]

To access the skill 1’s sub-document, the mongo shell query would be:

db.collection.find({ "skills.id": 1 }, { "skills.$": 1, _id: 0 } )

The output has the skill 1’s data:

{
        "skills" : [
                {
                        "id" : 1,
                        "name" : "DrillHole",
                        "status" : "PENDING",
                        "parameter" : "10"
                }
        ]
}