I have a MongoDB collection with the following format:
{
"_id" : ObjectId("5b6b112d1bbd972848b97df4"),
"team" : "Switzerland",
"Game" : [
{
"City" : "Nizhny Novgorod",
"T2N" : "Costa Rica",
"T1N" : "Switzerland",
"ST" : "Nizhny Novgorod Stadium",
"T1S" : "2",
"Date" : "6/27/2018",
"T2S" : "2"
},
{
"City" : "Kaliningrad",
"T2N" : "Serbia",
"T1N" : "Switzerland",
"ST" : "Kaliningrad Stadium",
"T1S" : "2",
"Date" : "6/22/2018",
"T2S" : "1"
},
{
"City" : "Rostov-on-Don",
"T2N" : "Brazil",
"T1N" : "Switzerland",
"ST" : "Rostov Arena",
"T1S" : "1",
"Date" : "6/17/2018",
}]
}
I am trying to run the following query: db.test.find({"Game.T1S":{$gte:3}}).pretty() But this returns data in the following format:
{
"_id" : ObjectId("5b6b112d1bbd972848b97df4"),
"team" : "Switzerland",
"Game" : [
{
"City" : "Nizhny Novgorod",
"T2N" : "Costa Rica",
"T1N" : "Switzerland",
"ST" : "Nizhny Novgorod Stadium",
"T1S" : "2",
"Date" : "6/27/2018",
"T2S" : "2"
},
{
"City" : "Kaliningrad",
"T2N" : "Serbia",
"T1N" : "Switzerland",
"ST" : "Kaliningrad Stadium",
"T1S" : "2",
"Date" : "6/22/2018",
"T2S" : "1"
},
{
"City" : "Rostov-on-Don",
"T2N" : "Brazil",
"T1N" : "Switzerland",
"ST" : "Rostov Arena",
"T1S" : "1",
"T2S" : "3"
"Date" : "6/17/2018",
}]
}
I want result to be just
db.test.find({"Game.T1S":{$gte:3}}).pretty() But this returns data in the following format:
{
"_id" : ObjectId("5b6b112d1bbd972848b97df4"),
"team" : "Switzerland",
"Game" : [
{
"City" : "Rostov-on-Don",
"T2N" : "Brazil",
"T1N" : "Switzerland",
"ST" : "Rostov Arena",
"T1S" : "1",
"T2S" : "3"
"Date" : "6/17/2018",
}]
}
That is the result for game should only contain the record with T1S >= 3 and not the other records as in the first output. Is there any way I can achieve this?