In the header, the issue is clearly defined. I have a collection called "results" containing multiple documents:
{
"_id" : "item_e4a2086048057ac9",
"home" : "FH>87218379012",
"username:" : "Jon Doe",
"Apps" : {
"game" : {
"InVals" : {
"ET" : {
"et1" : 1,
"et2" : 88,
"et3" : 7,
"et4" : 0.68,
"et5" : 5253,
"et6" : "7233-AL",
"et7" : "23-PL",
"et8" : "791-GY"
}
},
"OutVals" : {
"ET" : 74.00
}
}
},
"PAT" : 74
}
Next document:
{
"_id" : "item_a90a2086048057ac9",
"home" : "FH>87218379012",
"username:" : "Jon Doe2",
"Apps" : {
"game" : {
"InVals" : {
"ET" : {
"et1" : 0,
"et2" : 9,
"et3" : 96,
"et4" : 3218,
"et5" : 6,
"et6" : "65-AL",
"et7" : "265-PL",
"et8" : "4-GY"
}
},
"OutVals" : {
"ET" : 4.00
}
}
},
"PAT" : 4
}
And so on... Now I want to retrieve all "PAT" fields from specific documents where the "home" field equals "FH>87218379012", then sort them in descending order and store them in an array variable like this:
var resultsArray = [74, 4....,n];
If necessary, I am open to solutions that involve storing each "PAT" value in a separate variable, sorting them individually, and later compiling them into an array. Ultimately, I need all "PAT" values from documents with "FH>87218379012" as their "home" field in descending order in an array.
Is this achievable without modifying my collection?