When working with Java to create a complex MongoDB query, I often log the query before executing it:
log.info("Filter: {}", queryFilter);
The logged query output typically looks like this:
And Filter{filters=[Filter{fieldName='FinInstrmGnlAttrbts.ClssfctnTp', value=RFBTCB}, [...] ]}
However, I would prefer for the logged query to be in a "Javascript form" that directly reflects how it would be executed in MongoDB, such as:
{$and : [ {'FinInstrmGnlAttrbts.ClssfctnTp' : 'RFBTCB'}, [...] ]}
This way, if an error occurs at any point, I can simply copy the query from the log and test it in MongoDB without having to manually retype the entire query.
Is there a way to achieve this desired format for logging the queries?