current documents fetched by db.test.find({})
[
{
"_id": "507f1f77bcf86cd799439011",
"name": "XYZ",
"score": 123
},
{
"_id": "507f1f77bcf86cd799439011",
"name": "ASD",
"score": 12
},
{
"_id": "507f1f77bcf86cd799439011",
"name": "YTR",
"score": 98
},
{
"_id": "507f1f77bcf86cd799439011",
"name": "LKJ",
"score": 752
},
{
"_id": "507f1f77bcf86cd799439011",
"name": "PLM",
"score": 345
}
]
And after executing this query db.test.idk({ idk })
against MongoDB the db.test.find()
should return:
[
{
"_id": "507f1f77bcf86cd799439011",
"name": "XYZ",
"score": 123
},
{
"_id": "507f1f77bcf86cd799439011",
"name": "ASD",
"score": 752
},
{
"_id": "507f1f77bcf86cd799439011",
"name": "YTR",
"score": 345
},
{
"_id": "507f1f77bcf86cd799439011",
"name": "LKJ",
"score": 12
},
{
"_id": "507f1f77bcf86cd799439011",
"name": "PLM",
"score": 98
}
]
As you can see the scores are updated but now LKJ
has the lowest score and ASD
has the highest value. How can i do it?
- Documents are just sample
- Actual documents are too much
- My though: I need alorithm and there is not any operator to help me to achieve it simpler.