Change all my documents nested document value

后端 未结 1 700
逝去的感伤
逝去的感伤 2020-12-21 10:31

In mongos shell how would I go through and change every document in reviews.category to \"category 2\"

My Documents Structure:

{
   \"_i         


        
相关标签:
1条回答
  • 2020-12-21 11:18

    You will have to do this yourself in your application code, by querying the document, and looping over all of your nested documents; and then save it back to MongoDB.

    In order to prevent race conditions with this, please have a look at the section compare and swap at http://www.mongodb.org/display/DOCS/Atomic+Operations

    There is currently an open ticket for this to add this functionality to MongoDB. You might want to up-vote it: https://jira.mongodb.org/browse/SERVER-1243

    0 讨论(0)
提交回复
热议问题