title: Using ternary operator to conditionally set value of a field
body: <p>I have an object, and I want to set one of the fields to the return of querying the database using the value of another field in the object.  The approach below returns <code>null</code>, as Im sure it's not right, but I can't figure out the best way to do this.</p>
  
  <p><code>shared_user_email</code> should be blank if <code>shared_user</code> is empty, but it should represent the return of a database query if <code>shared_user</code> is populated.</p>
  
  <p>I know that javascript variables are hoisted to the top of the application at runtime, but I seem to be falling victim to order of operations here.</p>
  
  <pre><code>    var newList = {
          title: $(ev.target).find('[name=title]').val(),
          description: $(ev.target).find('[name=description]').val(),
          dateCreated: today.toDateString(),
          owner: Meteor.userId(),
          owner_email: Meteor.user().emails[0].address,
          shared_user: $(ev.target).find('[name=shared_user]').val(),
          shared_user_email: shared_user_email_field
      }
  
      var shared_user_email_field = (newList.shared_user != '') ? Meteor.users.find({_id: $(ev.target).find('[name=shared_user]')
          .val()}).fetch()[0].emails[0].address : '';
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>here is the server side method that is invoked right after the object is created, which passes <code>newList</code> to the server:</p>
  
  <pre><code>    Meteor.call('addList', newList, function(err, list){
          console.log(shared_user_email_field);
          return list;
      });
  </code></pre>