Is there a floor function in Mongodb aggregation framework?

前端 未结 2 538
花落未央
花落未央 2020-12-20 20:58

I try to do some integer math in mongodb and have some problems. Is there a way to round doubles up or down in the mongo db aggregation framework?

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-20 21:25

    As per the comment from Stennie, the floor and ceiling methods are not supported.

    And as per my comment above, the best solution that I could find was just doing an operation that looks like: (num-mod(num,1)) which should yield the same result as the floor function.

提交回复
热议问题