node.js - mongoose使用aggregate 求和时,如何把string转为number类型然后再进行求和?
伊谢尔伦
伊谢尔伦 2017-04-17 15:26:24
0
1
660

mongoose使用aggregate 求和时,如何把string转为number类型然后再进行求和?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
小葫芦

This has nothing to do with mongoose. It mainly depends on whether this conversion function is provided in the aggregate operation of mongodb.
If there is a function that provides string to number, you can convert it in the $project operation.
I scanned the mongodb documentation
https://docs.mongodb.com/v3.2...
I did not find this function.

Consider using mapreduce.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template