In MongoDB, the $rand
aggregation pipeline operator returns a random float between 0 and 1.
The floating point value has up to 17 digits after the decimal point. Any trailing zeros are dropped, so the number of digits may vary.
The $rand
operator was introduced in MongoDB 4.4.2.