title: express-session entry not completely removed from mongodb
body: <p>I am using <a href="https://www.npmjs.com/package/express-session" rel="nofollow noreferrer">express-session</a> along with <a href="https://www.npmjs.com/package/connect-mongodb-session" rel="nofollow noreferrer">connect-mongodb-session</a> packages in a <code>nodeJS</code> app to store sessions in mongodb database.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>When I try to delete a session saved in the database using <code>req.session.destroy()</code> function, it removes user-related information from the session entry saved in a database but it doesn't remove the session entry completely from the database.</p>
  
  <p><strong>Question</strong></p>
  
  <p>How can i fix this problem? Why is session entry completely removed from the database? </p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>const expressSession = require('express-session');
  const MongoDbStore = require('connect-mongodb-session')(expressSession);
  
  const sessionStore = new MongoDbStore({
      uri: dbConnectionStr,
      collection: 'sessions'
  });
  
  app.use(expressSession({
      secret: 'sessionsecret',
      resave: false,
      saveUninitialized: false,
      store: sessionStore
  }));
  </code></pre>
  
  <p>code where <code>req.session.destroy</code> is called</p>
  
  <pre><code>const logout = (req, res) =&gt; {
      try {
  
           // destroy session saved in db
              req.session.destroy((error) =&gt; {
              if (error) {
                  throw new Error('something went wrong while logging out')
              }
              res.redirect('/login');
          });
  
      } catch (error) {
          res.status(400).send(utils.standardResponse('error', error.message));
      }
  };
  </code></pre>