title: Modifying the last element of an array in MongoDB
body: <p>I have an object structure like this:</p>
  
  <pre><code> {
      name: "...",
      pockets: [
          {
              cdate: "....",
              items: [...]
          }
          ...
      ]
   }
  </code></pre>
  
  <p>In an update operation, I want to add some records into the <em>items</em> field of the last <em>pocket</em> item. Using dot notation is the only way that I know to access a sub document, but I can't get what I want. So, I'm looking for something like these:</p>
  
  <ul>
  <li>pockets.-1.items</li>
  <li>pockets.$last.items</li>
  </ul>
  
  <p>Is it possible to modify the last element? If yes, how?</p>