mongoose使用aggregate 求和时,如何把string转为number类型然后再进行求和?
高洛峰2017-04-17 15:28:24
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.