Chapter 3: $project results

Currently I’m doing my Lab for $unwind but I don’t know how to truncate the average rating to one decimal, I know that exists $trunc for the $project stage but this won’t allow me to get one decimal, I was wondering if there is some simple approach to do it.

@ turboAza

Here’s an old trick from my Math days – to get a given number of decimal places in a number, multiply that number by the 10*(the number of decimal places), then truncate to an integer, then divide the result by the same value. HTH.