title: why my function to check if a user already exist in my database always return false?
body: <p>I want my function to return true or false but it seems to be returning false each time</p>
  <pre class="lang-js prettyprint-override"><code>function alreadyExist(login) {
     User.findOne({login: login}, (error, user) =&gt; {
      return (!error &amp;&amp; user);
    });
  }
  
  logRoute.post('/register', (req, res) =&gt; {
      let userData = req.body;
      let user = new User(userData);
      let login = user.login;
      let number = 0;
      while (alreadyExist(login)){
        number +=1;
        login = user.login+number.toLocaleString(undefined, {minimumIntegerDigits: 2});
      }
      if(number&gt;0)user.login = login;
      user.save((err, registeredUser) =&gt; {
        if (err) {
          console.log(err)
        } else {
          console.log(&quot;registered\n&quot; + registeredUser);
          res.status(200).send('user registered')
        }
      });
    }
  );
  </code></pre>
  <p>my code is supposed to add a digit after the user login if a user with the same login already exist but my code only add multiple user with the same login in my database, do you know why ?</p>