Why ? Aren't you validating queries here with a bunch of if statements ?
This is one of the reasons why we use ORM schemas like mongoose, to separate input data validation logic from the controler logic.
I'm just saying validating queries are a pain, so why don't we make schemas validation classes...