aggregate debugger mongoose
const util = require('util');
const debug = (data) => {
console.log(util.inspect(data, false, null, true));
};
const debugAggregate = async (model, pipeline) => {
for (const i=0; i<pipeline.length; i++) {
const p = pipeline.slice(0, i);
const result = await model.aggregate(p);
debug(p);
debug(result);
}
}