title: How to update the _id field in a mongodb document
body: <p>I have documents in the following format:</p>
  
  <pre><code>{
    _id: "1232014",
    account: "123",
    year: 2014,
    country: 826
  }
  </code></pre>
  
  <p>The <code>_id</code> field is made up of the <code>account</code> field and the <code>year</code> field combined.</p>
  
  <p>However, I've since found that the same account in the same year can have data in different countries, and I'm getting a duplicate key error.</p>
  
  <p>What I need to do is have the <code>country</code> field as part of the <code>_id</code> field too e.g.</p>
  
  <pre><code>_id: "1232014826"
  </code></pre>
  
  <p>Since I'm using a value from within the document as part of the update, I don't think I can use <code>$set</code>, so I've tried to use <code>save()</code> within a <code>forEach()</code> query instead:</p>
  
  <pre><code>db.account_data.find({"_id" : "1232014"}).forEach(function(doc) {
      doc._id = doc._id + doc.country;
      db.collection.save(doc);
  });
  </code></pre>
  
  <p>This isn't working.</p>
  
  <p>Is there any way to update <code>_id</code>? Or is this impossible because it is primary key field?</p>