Last active
August 16, 2019 18:52
-
-
Save FlavienBusseuil/00e9ca224a4d977bee063bdcc97aaeb2 to your computer and use it in GitHub Desktop.
Inline Conditional Object Initialization with Filter
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 = Object.assign( | |
...[ | |
{ filter1 }, | |
{ filter2 }, | |
condition && { filter3 }, | |
{ filter4 }, | |
].filter(Boolean), | |
); | |
db.collection.find(filters); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment