mongodb-js / connect-mongodb-session

Lightweight MongoDB-backed session store for Connect and Express
Apache License 2.0
176 stars 35 forks source link

method all callback not works #114

Open Striller18 opened 9 months ago

Striller18 commented 9 months ago

The method "all" is not working because the method "toArray" changed from callback to promise

Before

this.db.collection(this.options.collection).
      find({}).toArray(function(error, sessions) {
        if (error) {
          const e = new Error('Error gathering sessions');
          return _this._errorHandler(e, callback);
        } else if (sessions) {
          if (sessions) {
            return callback(null, sessions);
          }
        } else {
          return callback();
        }
      });

After

return this.db.collection(this.options.collection).find({}).toArray()
    .then( sessions => {
      return callback(null, sessions);
    })
    .catch( error =>{
      const e = new Error('Error finding sessions: ' + error.message);
      return _this._errorHandler(e, callback);
    })