title: Mongo error when updating: cannot use the part to traverse the element
body: <p>I am attempting to update my mongo collection with the following structure</p>
  
  <pre><code>{
      "_id" : "T6GqWsi9qSxnyGzgC",
      "spec_name" : "test",
      "version" : "test",
      "message_type" : "test",
      "message_trigger" : "test",
      "segments" : [
          {
              "segment_id" : "MSH",
              "sequences" : [
                  {
                      "dataType" : "ST",
                      "optionality" : "R",
                      "name" : "Field Seperator"
                  },
                  {
                      "dataType" : "ST",
                      "optionality" : "R",
                      "name" : "Encoding Characters"
                  },
                  {
                      "dataType" : "HD",
                      "optionality" : "O",
                      "name" : "Sending Application"
                  },
                  {
                      "dataType" : "HD",
                      "optionality" : "O",
                      "name" : "Sending Facility"
                  },
                  {
                      "dataType" : "HD",
                      "optionality" : "O",
                      "name" : "Receiving Application"
                  },
                  {
                      "dataType" : "HD",
                      "optionality" : "O",
                      "name" : "Receiving Facility"
                  },
                  {
                      "dataType" : "TS",
                      "optionality" : "O",
                      "name" : "Data/Time Of Message"
                  },
                  {
                      "dataType" : "ST",
                      "optionality" : "O",
                      "name" : "Security"
                  },
                  {
                      "dataType" : "CM",
                      "optionality" : "R",
                      "name" : "Message Type"
                  },
                  {
                      "dataType" : "ST",
                      "optionality" : "R",
                      "name" : "Message Control ID"
                  },
                  {
                      "dataType" : "PT",
                      "optionality" : "R",
                      "name" : "Processing ID"
                  },
                  {
                      "dataType" : "NM",
                      "optionality" : "O",
                      "name" : "Sequence ID"
                  },
                  {
                      "dataType" : "ST",
                      "optionality" : "O",
                      "name" : "Continuation Pointer"
                  },
                  {
                      "dataType" : "ID",
                      "optionality" : "O",
                      "name" : "Accept Acknowledgment Type"
                  },
                  {
                      "dataType" : "ID",
                      "optionality" : "O",
                      "name" : "Application Acknowledgment Type"
                  },
                  {
                      "dataType" : "ID",
                      "optionality" : "O",
                      "name" : "Country Code"
                  },
                  {
                      "dataType" : "ID",
                      "optionality" : "O",
                      "name" : "Character Set"
                  },
                  {
                      "dataType" : "CE",
                      "optionality" : "O",
                      "name" : "Principal Language Of Message"
                  }
              ]
          }
      ],
      "segment_groups" : [
          {
              "grouping_id" : 692335,
              "segments" : [
                  {
                      "segment_id" : "test",
                      "group_segment_id" : 597268,
                      "sequences" : [ ]
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I wish to append { value_one: "value", value_two: "value" } into the sequences array within segment_groups. My query looks like this: </p>
  
  <pre><code>db.messages.update({"segment_groups.segments.group_segment_id": 597268},{$push:{ "segment_groups.segments.$.sequences":{"value_one":"value", "value_two":"value"}}})
  </code></pre>
  
  <p>when attempting this i get the error: </p>
  
  <pre><code>"code" : 16837,
          "errmsg" : "cannot use the part (segment_groups of segment_groups.segments.0.sequences) to traverse the element ({segment_groups: [ { grouping_id: 692335, segments: [ { segment_id: \"test\", group_segment_id: 597268, sequences: [] } ] } ]})"
      enter code here
  </code></pre>
  
  <p>Ive been at this issue for a day now and have no come across any sound advice on how to resolve or how to restructure my collection. I am new to mongo and am not aware of best practices when structuring so any method needed to make this a better solution is valuable.</p>