Generate aggregate query as pure JSON
When we create an aggregrate query we can see a "Query Preview" which shows a JavaScript fragment that, when executed, will execute the request. However, what I'd like is the ability to see the query as a pure JSON document that can then be copied/pasted as pure JSON. For example, field names would need surrounding quotes.
Hi Neil,
Query Preview is exactly that
There is even a copy-to-clipboard button for ease of use. I hope this helps.
-
Anonymous commented
Howdy my friend. I look at the "Query Preview" and, for example ... see:
db.results.aggregate(
// Pipeline
[
// Stage 1
{
$match: {
"processApp": "DEF1",
"processName": "Loan 2",
"name": "TP1"
}
}
];If we look at the body of the aggregate, I'm hoping you will see that is "JavaScript" and not "JSON". For example:
1. It contains comments (//). This is not allowed in JSON
2. Some of the field names are unquoted ... for example $match instead of "$match"What this means is that if I have a large pipeline and want to pass it as JSON, I have to copy it from Query Preview and then manually work through it to convert it to JSON ... my hope/desire was a mechanism to generate and output a "ready to use" JSON representation of the aggregation pipeline.
Neil