Nesar
Nesar

Reputation: 96

How do i write an aggregation query with { explain : true } in mongoose

This is the code not working.

Model.aggregate([{ "$match": query }]).explain(true);

Upvotes: 4

Views: 3247

Answers (1)

SVUser
SVUser

Reputation: 415

Adding ,{ explain: true } after the aggregation array into a MyModel.aggregate(array, options) type of statement didn't work for me in Mongoose 5.2.7 / MongoDB 3.6.6. Luckily, MyModel.aggregate(array).explain() is now available and documented https://mongoosejs.com/docs/api.html#aggregate_Aggregate-explain

Upvotes: 2

Related Questions