MongoDB 聚合框架中将小数四舍五入到最接近的整数

Kam*_*iya 1 rounding mongodb mongodb-query aggregation-framework

我已经浏览了以下网站,但无法得到我的解决方案。 四舍五入到小数点后 2 位

我有以下小数并想四舍五入到最接近的整数:

34.56 => 35
34.67 => 35
34.12 => 34
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这个:

            "$subtract": [
                        "$x",
                        { "$mod": ["$x", 1] }
                    ]
Run Code Online (Sandbox Code Playgroud)

与Oracle Round 函数相同

我可以在 MongoDB 中做什么?