Last active
August 5, 2019 20:25
-
-
Save FlavienBusseuil/2a97357fdcd232794f8fa0ea44396557 to your computer and use it in GitHub Desktop.
Inline Conditional Array Initialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aggregationStages = [ | |
stage1, | |
stage2, | |
condition && stage3 | |
stage4, | |
].filter(Boolean); | |
db.collection.aggregate(aggregationStages); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment