Hello,
I have written the following code
db.movies.aggregate([
{
$match: {
languages: "English"
}
},
{
$unwind: "$cast"
},
{
$group: {
_id: "$cast",
numFilms: {
$sum: 1
},
average : {
$avg : "$imdb.rating"
}
}
},
{
$sort: {
numFilms: -1,
average: -1
}
}
])
And I would like to display the truncated average, but $tunc can not be used inside $group, how can I solve this?
Thanks