I have a MongoDB aggregation query in which I have the following:
{ $match: { version: versionNumber }
The 'versionNumber' is an optional input parameter to the aggreagation. If this versionNumber is not provided, then I do not want this match to be performed.
Currently, if the versionNumber is not supplied, the match still happens and I get a blank query output.
Is there a way in Mongo to do this? Thanks!