I want to verify that the mongoose query that I'm creating is using my indexes. Is there a way that I can view the final query that is generated to mongodb so that I can run a .explain() on the query?
I can guess what the query it is generating is, but just wanted to verify.
e.g.
var query = Post.find()
.regex('lowerCaseTitle', searchRegEx)
.$gte('status',0)
.$lt('start', now)
.$gt('end',now)
.sort('total', -1)
.limit(50);
You can get the execution query using the debug option on mongoose:
mongoose.set('debug', true);
or
mongoose.set('debug', function (collectionName, method, query, doc, options) {
//
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With