title: If statement socket io mongodb nodejs
body: <p>How could I check in this code if <code>userally</code> or <code>enemyally</code> doesnt exist and then just not send them. Should I make if statement and then make two more <code>emits</code> without user ally or without enemy ally or without both?</p>
  
  <pre><code>AllianceMember.findOne({username: user.username}).then((userally) =&gt; {
   AllianceMember.findOne({username: enemy.username}).then((enemyally) =&gt; {
        io.emit('fight-win', {
            username: user.username,
            useralliance: userally.ally_title,
            enemyalliance: enemyally.ally_title,
            enemyname: enemy.username,
  });
  </code></pre>