Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created November 14, 2018 16:53
Show Gist options
  • Save sibelius/1b6bf5438b4fb7379da075a684563b7a to your computer and use it in GitHub Desktop.
Save sibelius/1b6bf5438b4fb7379da075a684563b7a to your computer and use it in GitHub Desktop.
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment