How to execute update ($set) queries in MongoDB Compass tool?

MongodbMongodb QueryMongodb Compass

Mongodb Problem Overview


I'm new to MongoDB Compass tool and am trying to update a field in my collection. Please can someone suggest where the update query must be written. Could find no options or panes in the tool to write custom queries be it selection / updation for that matter.

In the Default Window only the selection/projection/restriction options are found. Any help is much appreciated.

Mongodb Solutions


Solution 1 - Mongodb

I had the same issue, it looks like a simple feature to implement (since document updates are possible) but... AFAIK there is no such option in compass, you can do it through mongodb shell (CLI client).

UPDATE: And it seems that it is possible now, although in beta, in the latest version (1.22.1) there is a "_MongoSH Beta" in the bottom left corner of the window. Thx to @Boštjan Pišler for the hint about a new feature.

Solution 2 - Mongodb

The tool was recently updated with a shell (currently in beta) which is accessible by clicking the dark bar on the bottom of the window "_MongoSH"

Mongosh beta tab

Solution 3 - Mongodb

You can use mongo MongoSH. Currently its in Beta.

enter image description here

Solution 4 - Mongodb

Just move your mouse over a document and find a little pencil. You will enter in update mode. You can change fields, values, arrays, etc.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPatrickView Question on Stackoverflow
Solution 1 - MongodbIvan MarjanovicView Answer on Stackoverflow
Solution 2 - MongodbBoštjan PišlerView Answer on Stackoverflow
Solution 3 - MongodbMahesh GarejaView Answer on Stackoverflow
Solution 4 - MongodbArturoView Answer on Stackoverflow