search

Home  >  Q&A  >  body text

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

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

伊谢尔伦伊谢尔伦2768 days ago638

reply all(1)I'll reply

  • 高洛峰

    高洛峰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.

    reply
    0
  • Cancelreply