title: How to create an empty field if the field doesn't exist in MongoDB
body: <p>I have a document that is created on weakly bases (<code>field delimeter</code> hold date) for each user's week.
  Every time the user session expires I check to see the user has a document for that particular week (so that all updates dont fail)</p>
  
  <p>I am trying to avoid 2 fetches : <code>1)</code> a fetch to check if the document exists, <code>2)</code> create another query that creates or not that document depending on whether it exists already</p>
  
  <p>I was wondering if there is such a function within <code>mongo</code>... Create if doesn't exist otherwise do nothing?</p>
  
  <p>Currently, <code>upsert</code> <code>inserts</code> if it is not there or <code>updates</code> if it is there. Thus, is not a valid solution. I need  <code>if ( !exist){ update/insert ) else { do nothing }</code></p>
  
  <pre><code>public function createUserSocialWallForUser( MongoId $userMongoID, $delimeter ) {
          $db = $this-&gt;db()-&gt;socialWall;
  
          $where = array( 'userId' =&gt;  $userMongoID, 
                          'delimeter' =&gt; $delimeter
                        );
          $data = array(  'userId' =&gt;  $userMongoID, 'delimeter' =&gt; $delimeter, 'event' =&gt; array() );
          $option = array ('upsert' =&gt; true);
          $db-&gt;update( $where, $data, $option); 
      }
  </code></pre>