title: Moving mongo field within document if it exists
body: <p>We are refactoring a mongo database, and I'd like to pull the value for one field, and place it into a hash in array in another field. Here is how the data looks in the document before:</p>
  
  <pre><code>basecampURL: "https://basecamp.com/123/",
  trackingSystems: [
      {
          type: "github",
          url: "https://github.com/org/repo/issues/"
      }
  ]
  </code></pre>
  
  <p>And here is what I'm hoping to accomplish:</p>
  
  <pre><code>trackingSystems: [
      {
          type: "basecamp",
          url: "https://basecamp.com/123/"
      },
      {
          type: "github",
          url: "https://github.com/org/repo/issues/"
      }
  ]
  </code></pre>
  
  <p>I've tried a few variations of this code, and where I'm running into an issue is when referencing the found variable for basecampURL, all of the examples on <a href="http://docs.mongodb.org/manual/core/update/#update-a-field-in-a-document" rel="noreferrer" title="MongoDB Update">MongoDB Update</a> are using a string. </p>
  
  <pre><code>db.projects.update( 
      { basecampURL: '.+' }, 
      { $push: 
          { trackingSystems: 
              { 
                  type: 'basecamp',
                  url: basecampURL // this isn't valid, also tried $.basecampURL
              }
          },
        $unset: 
          { basecampURL: '.+' }
      },
      { multi: true}
  )
  </code></pre>
  
  <p>It seems like I'm not finding how to reference the found item's properties, but I've been wondering if I need to do store the found variable prior to the update. </p>