My goal is to find two random documents. Each document has a UserCount. The usercount difference between these two document
Actually, I’m getting an output below
{
"UserCount": 10,
"_id": 30,
},
{
"UserCount": 22,
"_id": 31,
},
{
"UserCount": 30,
"_id": 32,
},
{
"UserCount": 35,
"_id": 33,
}
expecting output below.
{
"UserCount": 10,
"_id": 30,
"difference" : "12",
},
{
"UserCount": 22,
"_id": 31,
"difference" : "8",
},
{
"UserCount": 30,
"_id": 32,
"difference" : "5",
},
{
"UserCount": 35,
"_id": 33,
"difference" : "0",
}
using MongoDB query, it is very difficult to solve this problem.