title: Setting an entity's key in NDB in Google App Engine
body: <p>How do I set an <code>entity</code>'s key in my code.</p>
  
  <p>Example, I have a user class</p>
  
  <pre><code>class User(ndb.Model)
    email
  </code></pre>
  
  <p>I want to be able to set email property and query using email property</p>
  
  <p><code>my_user = User(email='xyz@ab.com')</code></p>
  
  <p>Above statement sets email property, but Google App Engine generates its own key. </p>
  
  <p>Can I set the key using User(key='xyz@ab.com')</p>
  
  <p>If I can set the key property in a entity, how do I query for an entity using the key</p>
  
  <p>Does this work
  User.query(key='xyz@ab.com').get()</p>
  
  <p>I realize that I can query using <code>email</code> as a property, but unfortunately I can't do that in context of a <code>transaction</code>.</p>
  
  <p>That is the reason I am asking how to get(), set() by keys.</p>
  
  <p>Also, when I end up querying by properties, I need to create indexes on properties, which I know will be unique</p>