title: Mongoose method to return id
body: <p>I'm struggling to code a method in my mongoose model that returns only an id of a specific record.</p>
  
  <p>This is my (simplified) schema:</p>
  
  <pre><code>var PersonaSchema   = new Schema({
      email: { type: String, unique: true },
      personal_firstname: String,
      created_at: { type: Date },
      updated_at: { type: Date }
  });
  </code></pre>
  
  <p>I would like to search for a record by email, than return the id if it exists. Currently I have this method setup as a static method, which does not work as suspected. It does not return the id, but the whole mongoose object.</p>
  
  <pre><code>PersonaSchema.statics = {
    getPersonaId: function getPersonaId(email, cb) {
      this.findOne({ email: email }).select("_id").exec(function(err, persona) {
          if(err) {
              throw err;  
          } else {
              if(persona){
                  return persona._id;
              } else {
                  return;
              }
          }
      });
    }
  }
  </code></pre>
  
  <p>Any pointers are much appreciated.</p>
  
  <p>EDIT: I was not quite clear in my question. What I want to do is get the persona id as a single value in my controller method.</p>
  
  <p>Underneath I have a now working version, with a callback version. However, I would like it to be without a callback. So that I send an email to a static function, which returns the persona._id. How would I do that, without a callback?</p>
  
  <pre><code>var personaId = Persona.addPersonaId(personaData, function(err, persona, data) {
      if(err){
          console.log(err)
      } else {
          console.log(data);
      }
  });
  </code></pre>