Hi All,
I am new to MongoDB. I want to see all records from a collection where symbol is in the list of all distinct symbols which have AdjClose value less than 60.
My data looks like
{
"_id" : ObjectId("604b67f16cebca011964cee6"),
"sym" : "COST",
"DateText" : "2008-01-02T12:00:00",
"AdjClose" : NumberDecimal("67.22"),
"PeriodChange" : NumberDecimal("0"),
}
{
"_id" : ObjectId("604b67f16cebca011964cee7"),
"sym" : "COV",
"DateText" : "2008-01-02T12:00:00",
"AdjClose" : NumberDecimal("42.4"),
"PeriodChange" : NumberDecimal("0"),
}
I am trying this query.
{"sym" :
{ "$in" :
[
{
"distinct" : "StocksTimeSeries",
"key" : "sym",
"query" : { "AdjClose" : { "$lt" : "50"}}
}
]
}
}
But it isn’t returning any record.
On the other hand, if I try to use shell command, it works.
db.getCollection("StocksTimeSeries").find({"sym" :{"$in" : db.getCollection('StocksTimeSeries').distinct("sym",{"AdjClose":{ "$lt" : 50 }}) }})
Considering these two records, I am expecting the result to be second record.
{
"_id" : ObjectId("604b67f16cebca011964cee7"),
"sym" : "COV",
"DateText" : "2008-01-02T12:00:00",
"AdjClose" : NumberDecimal("42.4"),
"PeriodChange" : NumberDecimal("0"),
}
Could you guys please help me.
Thanks