MongoDB rename database field within array

前端 未结 6 694
难免孤独
难免孤独 2020-11-28 09:16

I need to rename indentifier in this:

{ \"general\" : 
  { \"files\" : 
    { \"file\" : 
      [  
        {  \"version\" : 
          {  \"sof         


        
6条回答
  •  一向
    一向 (楼主)
    2020-11-28 09:43

    As mentioned in the documentation there is no way to directly rename fields within arrays with a single command. Your only option is to iterate over your collection documents, read them and update each with $unset old/$set new operations.

提交回复
热议问题