In MongoDB, the $size
aggregation pipeline operator counts and returns the total number of items in an array.
The $size
operator accepts one argument. The argument can be any valid expression that resolves to an array.
In MongoDB, the $size
aggregation pipeline operator counts and returns the total number of items in an array.
The $size
operator accepts one argument. The argument can be any valid expression that resolves to an array.
In MongoDB, the $setUnion
aggregation pipeline operator accepts two or more arrays and returns an array containing the elements that appear in any of those input arrays.
$setUnion
accepts two or more arguments, all of which can be any valid expression as long as they each resolve to an array. $setUnion
treats the arrays as sets.
In MongoDB, the $setIsSubset
aggregation pipeline operator accepts two arrays and returns true
when the first array is a subset of the second, and false
when it isn’t.
The first array is also considered a subset when it equals the second array.
Continue readingIn MongoDB, the $setIntersection
aggregation pipeline operator accepts two or more arrays and returns an array that contains the elements that appear in all input arrays.
$setIntersection
accepts two or more arguments, all of which can be any valid expression as long as they each resolve to an array. $setIntersection
treats the arrays as sets.
In MongoDB, the $setEquals
aggregation pipeline operator compares two or more arrays and returns true
 if they have the same distinct elements and false
 otherwise.
$setEquals
accepts two or more arguments, all of which can be any valid expression as long as they each resolve to an array. $setEquals
treats the arrays as sets.
In MongoDB, the $setDifference
aggregation pipeline operator accepts two sets and performs a relative complement of the second set relative to the first. It returns an array containing the elements that only exist in the first set.
$setDifference
accepts two arguments, both of which can be any valid expression as long as they each resolve to an array. $setDifference
treats the arrays as sets.
In MongoDB, the $sampleRate
aggregation pipeline stage matches a random selection of input documents.
The number of documents selected approximates the sample rate expressed as a percentage of the total number of documents.
The $sampleRate
operator was introduced in MongoDB 4.4.2.
In MongoDB, the $reverseArray
aggregation pipeline operator reverses the order of items in an array.
It accepts an array expression as an argument and returns an array with the elements in reverse order.
Continue readingIn MongoDB, the $range
aggregation pipeline operator returns a generated sequence of numbers in an array.
This sequence of numbers is based on the input values you provide.
Continue readingIn MongoDB, the $round
aggregation pipeline operator rounds a number to a whole integer or to a specified decimal place.
You have the option of specifying how many decimal places for which to round the number. To do this, pass a second argument. The first argument is the number to round, and the second (optional) argument is the number of decimal places to round it to.
Continue reading