Query.prototype.explain()

Parameters
  • [verbose] «String» The verbosity mode. Either ‘queryPlanner’, ‘executionStats’, or ‘allPlansExecution’. The default is ‘queryPlanner’
Returns:
  • «Query» this

Sets the explain option, which makes this query return detailed execution stats instead of the actual query result. This method is useful for determining what index your queries use.

Calling query.explain(v) is equivalent to query.setOption({ explain: v })

Example:

  1. const query = new Query();
  2. const res = await query.find({ a: 1 }).explain('queryPlanner');
  3. console.log(res);