Last active
August 16, 2019 18:23
-
-
Save FlavienBusseuil/245e748929d4db66d30abafc050de478 to your computer and use it in GitHub Desktop.
ES6 Inline Conditional Object 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 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