Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FlavienBusseuil/2a97357fdcd232794f8fa0ea44396557 to your computer and use it in GitHub Desktop.
Save FlavienBusseuil/2a97357fdcd232794f8fa0ea44396557 to your computer and use it in GitHub Desktop.
Inline Conditional Array Initialization
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