I have a collection with array field:
{[
name:String
buyPrice:Int
sellPrice:Int
]}
I am trying to find min and max buy/sell price. At some entries buy or sell price is zero so I need to find min price but greater than zero. Here is my query:
{
name: '$_id',
maxBuyPrice: {
$max: '$commodities.buyPrice'
},
minBuyPrice: {
$min: '$commodities.buyPrice'
},
maxSellPrice: {
$max: '$commodities.sellPrice'
},
minSellPrice: {
$min: '$commodities.sellPrice'
}
}
I can't use $match operator with $gt because I can lost entries with max values