title: How do I change the primary key in a rethinkdb document?
body: <p>Based on <a href="https://www.rethinkdb.com/api/javascript/replace/" rel="nofollow">the RethinkDB replace() docs</a> I am trying to change the primary key of a document. In this case, the primary key is <code>email</code>:</p>
  
  <pre><code>var renamePerson = function(originalEmail, newEmail, cb){
      rethink.db(DATABASE).table(TABLE).get(originalEmail).replace({email: newEmail}).run(dbConnection, cb)
  }
  </code></pre>
  
  <p>This should work, but <code>unchanged</code> is <code>1</code>, and looking up the new document doesn't seem to return any results. </p>
  
  <p><strong>How can I change the primary key of a document?</strong></p>