Why can't I run the MongoDB update explanation?

I am trying to explain the mongoDB update; but nothing happens? Mongo does not support this?

> db.movies.update({"actors.name": "Christian Bale"}, {$set: {"actors.$.name": "Christina Bale"}}, {$explain: 1}); > 

I tried other options using .explain() and ._addSpecial("$explain", 1") . In both cases, the following error occurs:

Thu Aug 1 11: 26: 46.368 JavaScript execution failed: TypeError: Unable to invoke explain method undefined

+4
source share
2 answers

I believe that the following will allow you to call up an explanation at your request.

  db.movies.explain().update({your_query}) 

Hope this helps if you need more information let me know.

+6
source

Why do you want to call an explanation when updating? AFAIK, explain, will show you how your query will retrieve rows, so you can just do:

 db.movies.find( {$query: {"actors.name": "Christian Bale"}}, {$explain: 1} ); 
0
source

Source: https://habr.com/ru/post/1235192/


All Articles