Is there a gender function in the Mongodb aggregate structure?

I am trying to do some math in mongodb and have some problems. Is there a way to combine doubling up or down in the mongo db aggregation structure?

+6
source share
2 answers

According to a comment from Stennie, floor and ceiling methods are not supported.

And according to my comment above, the best solution I could find was simply to perform an operation that looks like this: (num-mod (num, 1)), which should give the same result as the floor function.

+9
source

Starting with MongoDB 3.2 , you can use the following arithmetic aggregation operators:

which allow you to convert to an integer from any side you want. The syntax is simple: { $function: <number> }

+1
source

All Articles