Last active
January 2, 2020 20:44
-
-
Save FlavienBusseuil/481f1be507db004c60cb125cf6916ccd to your computer and use it in GitHub Desktop.
Inline Conditional Object Initialization with Spread Operator
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 filters = { | |
filter1, | |
filter2, | |
...(condition && { filter3 }), | |
filter4, | |
}; | |
db.collection.find(filters); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment