Filter a collection but sort on inner property
<p>Considering that I have a collection of documents like below and I want to get information returned as follows:</p>

<p>Select all the entries from a campaign with <code>campaignID = 12</code>, sort by <code>entries.questionscorrect</code> in descending order with a limit of 10.</p>

<p>I have made a stab at a number of queries but I seem to be getting stuck on the fact that I am selecting on one level but want to order on a lower level i.e. property.</p>

<p>Here's what I have so far:</p>

<p><code>db.getCollection('main').find({"id":4}, {"entries": 1}).sort({"questionscorrect": -1}).limit(2)</code></p>

<p>How can I write this in either Go (Mgo) syntax or straight MongoDB query please?</p>

<p>I keep getting returned information but sorted on the number of</p>

<pre><code>{
    "_id": ObjectId("57f4a590a4be269aa54a0505"),
    "campaignID": 12,
    "name": "name-here",
    "description": "description-here",
    "entries": [{
        "id": 1,
        "nickname": "conorh",
        "name": "conor h***",
        "email": "ch@gmail.com",
        "agreeTerms": true,
        "optInMarketing": false,
        "questionscnswered": 10,
        "questionscorrect": 3
    }, {
        "id": 2,
        "nickname": "bobs",
        "name": "bob smyth",
        "email": "bs12121@gmail.com",
        "agreeTerms": true,
        "optInMarketing": false,
        "questionscnswered": 10,
        "questionscorrect": 6
    }, {
        "id": 3,
        "nickname": "jd12",
        "name": "jane doe",
        "email": "janedough@gmail.com",
        "agreeTerms": true,
        "optInMarketing": false,
        "questionscnswered": 10,
        "questionscorrect": 1
    }]
}
</code></pre>