Skip to content

Instantly share code, notes, and snippets.

@aaronbassett
Created December 4, 2019 13:31
Show Gist options
  • Save aaronbassett/261338d0399948b38b06871e27cbe3ab to your computer and use it in GitHub Desktop.
Save aaronbassett/261338d0399948b38b06871e27cbe3ab to your computer and use it in GitHub Desktop.
[{
$addFields: {
fizzbuzz: {
$switch: {
branches: [{
case: {
$and: [{
$eq: [{
$mod: ["$counter", 3]
}, 0]
}, {
$eq: [{
$mod: ["$counter", 5]
}, 0]
}]
},
then: "FizzBuzz"
},
{
case: {
$eq: [{
$mod: ["$counter", 3]
}, 0]
},
then: "Fizz"
},
{
case: {
$eq: [{
$mod: ["$counter", 5]
}, 0]
},
then: "Buzz"
}
],
default: ""
}
}
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment