$choose
Chooses one element from an array of possible choices with uniform probability.
Optionally chooses with probability proportional to a provided weights
array.
Options¶
from
(required) Array of values or operators to choose from.weights
(optional) Array of weightings (must be the same length asfrom
).
Example¶
{
"status": {
"$choose": {
"from": ["read", "unread", "deleted"],
"weights": [2, 1, 1]
}
}
}
{
"status": "read"
}
{
"status": "unread"
}
{
"status": "deleted"
}