How to dynamically build mongodb query
问题 I have a match expression in a mongodb aggregation. There are 3 fields that are included in the match but they don't all always contain data. I only want to include the fields in the match if the field isn't empty. This is what the match looks like if all fields have data but for example, if the array used for studentGradeLevels is empty, then I don't want to include it or I want the query to still return data ignoring the empty parameter. $match: { "school._id": "7011", "studentGradeLevels":