title: Mongodb update deeply nested subdocument
body: <p>I have a document structure that is deeply nested, like this: </p>
  
  <pre><code>{id: 1, 
   forecasts: [ { 
               forecast_id: 123, 
               name: "Forecast 1", 
               levels: [ 
                  { level: "proven", 
                    configs: [
                              { 
                                config: "Custom 1",
                                variables: [{ x: 1, y:2, z:3}]
                              }, 
                              { 
                                config: "Custom 2",
                                variables: [{ x: 10, y:20, z:30}]
                              }, 
                      ]
                  }, 
                  { level: "likely", 
                    configs: [
                              { 
                                config: "Custom 1",
                                variables: [{ x: 1, y:2, z:3}]
                              }, 
                              { 
                                config: "Custom 2",
                                variables: [{ x: 10, y:20, z:30}]
                              }, 
                      ]
                  }
              ]
          }, 
      ]
  
  }
  </code></pre>
  
  <p>I'm trying to update the collection to insert a new config, that looks like this: </p>
  
  <pre><code>newdata =  {
    config: "Custom 1", 
    variables: [{ x: 111, y:2222, z:3333}]
  }
  </code></pre>
  
  <p>I'm trying something like this in mongo (in Python):</p>
  
  <pre><code>db.myCollection.update({"id": 1, 
                          "forecasts.forecast-id": 123, 
                          "forecasts.levels.level": "proven", 
                          "forecasts.levels.configs.config": "Custom 1"
                           },
                           {"$set": {"forecasts.$.levels.$.configs.$": newData}}
                        )
  </code></pre>
  
  <p>I'm getting "Cannot apply the positional operator without a corresponding query field containing an array" error though. What is the proper way to do this in mongo? This is mongo v2.4.1. </p>