title: How to delete element on document by key in Mongo?
body: <p>I have the following Mongo document:</p>
  
  <pre><code>"parameters" : {
      "59209f26470e6c8d0b3c986b" : {
          "Speed" : "900"
      },
      "59209f31470e6cb90e3c986b" : {
          "Weight" : [
              "1"
          ]
      }
  },
  </code></pre>
  
  <p>I need to delete element from <code>parameters</code> by key <code>"59209f26470e6c8d0b3c986b"</code>. How to do that?</p>
  
  <p>I tried:</p>
  
  <pre><code>$new = array('$pull' =&gt; array("parameters" =&gt; $this-&gt;mongoDbID($id)));
  
  $this-&gt;collection-&gt;update(array("parameters" =&gt; []), $new);
  </code></pre>
  
  <p>Also I tried:</p>
  
  <pre><code>$this-&gt;collection-&gt;update(array(), array('$pull'=&gt;array('‌​parameters'=&gt; $id)));
  </code></pre>
  
  <p>I tried also:</p>
  
  <pre><code>$this-&gt;collection-&gt;update(
              array(),
              array('$pull' =&gt; array('parameters' =&gt; $id, []))
          );
  </code></pre>
  
  <p>It gives me:</p>
  
  <blockquote>
    <p>localhost:27017: Cannot apply $pull to a non-array value</p>
  </blockquote>
  
  <p><strong>Full document:</strong></p>
  
  <pre><code> &gt; db.objects.find().pretty()
      {
          "_id" : ObjectId("5920b488470e6c910b3c986d"),
          "name" : "dadasd",
          "category_id" : "591efb0f470e6ccc143c9873",
          "prototype_id" : "591ed2f0470e6ccc143c986e",
          "parameters" : {
              "5920a907470e6cf80d3c986b" : {
                  "adadad" : "dad"
              }
          },
          "parameters_type" : {
              "5920a907470e6cf80d3c986b" : NumberLong(1)
          },
          "available" : "1"
      }
  </code></pre>