如何在mongodb聚合中获得嵌套数组的总和?

时间:2018-06-15 15:27:07

标签: mongodb sum aggregate

My Array就是这样,

[data] =>排列                 (                     [0] =>排列                         (                             [test] => 164.765                         )

                [1] => Array
                    (
                        [test] => 26.1
                    )

                [2] => Array
                    (
                        [test] => 194.564
                    )

                [3] => Array
                    (
                        [test] => 54
                    )

                [4] => Array
                    (
                        [test] => 99.753
                    )

                [5] => Array
                    (
                        [test] => 32.735
                    )

                [6] => Array
                    (
                        [test] => 2715.865
                    )

                [7] => Array
                    (
                        [test] => 94.595
                    )
            )

通过使用$ sum我一直得到0。有没有办法得到这个数组的总和?

0 个答案:

没有答案